Definition: |
include pGUI.e
cbfunc res = Icallback("routine") |
Description: | Utility function. Shorthand for call_back(routine_id("routine")), but also validated as below. |
Comments: |
The routine name must be in scope, a literal string, and already defined at the point of use.
pGUI records a list of all callbacks generated via Icallback and validates all attempts to set callbacks against that list, since attempts to invoke something which is not a valid callback will always produce an indecipherable error message, or worse quietly terminate for no apparent reason, at least that is when said call is actually somewhere deep inside one of the precompiled IUP dynamic link libraries (which are written in C). The type cbfunc is used to validate that an atom address is (NULL or) the result of a previous call to Icallback, alternatively you could just use the atom type. string name = iup_name_from_cb(atom addr) can also be used to retrieve the name corresponding to a valid (non-null) Icallback address. You should not construct strings to pass to Icallback. Instead the function cbfunc func = iup_cb_from_name(string name) can be used when needed, and declare constant <possibly_otherwise_unused>=Icallback("routine"), immediately following the actual definition of each and every routine that you might require this for. It returns null when unable to find a previously generated Icallback of that name, and any name conflicts should have been caught by Icallback(). When translating C code to Phix, a common requirement is to replace (Icallback)xxx_cb with Icallback("xxx_cb") .
|
Example: |
include pGUI.e function quit_cb() return IUP_CLOSE; end function constant cb_quit = Icallback("quit_cb") Ihandle quit_btn = IupButton("Quit", cb_quit) |
See Also: | Ihandle, IupButton |