IupDetach
Disassociates an interface element from the dialog that contains it.
Parameters/Return
void IupDetach(Ihandle *element); [in C] IupDetach(element: iuplua_tag) [in IupLua3] iup.Detach(element: iuplua_tag) [in IupLua5] or element:detach() [in IupLua]
element: Identifier of the interface element to be detached.
Notes
This function does not destroy an interface element, but only removes the dialog that contains it so that it can be used in another dialog.
ATTENTION: At the moment, this function only works before the element is mapped by means of functions IupMap, IupShow, IupShowXY or IupPopup. The following example does not actually work!
Example
Inserts and removes a button box in/from a dialog.
In C
#include <stdlib.h> /* NULL */ #include "iup.h" static Ihandle *pc; /* Identifier of the hbox that contains the button box */ static Ihandle *cb; /* Identifier of the button box */ static int visivel=1; /* =1 if the button box is on the screen, =0 otherwise */ /* Function that displays the button box */ static int exibe (void) { if (visivel == 0) { IupHide(pc); IupAppend(pc, cb); IupShow(pc); visivel = 1; } return IUP_DEFAULT; } /* Function that hides the button box */ static int retira (void) { if (visivel == 1) { IupHide(pc); IupDetach(cb); IupShow(pc); visivel=0; } return IUP_DEFAULT; } void main (void) { Ihandle *d; /* Identifier of the dialog */ IupOpen(); /* Creates button box */ cb = IupFrame(IupVbox( IupButton(" Select " , "acao_select"), IupButton(" Line ", "acao_line"), IupButton("Poligono", "acao_poligono"), IupButton(" Circulo", "acao_circulo"), NULL)); /* Creates a box containing a canvas and the buttons */ pc = IupHbox(IupFrame(IupCanvas("acao_repaint")), cb, NULL); d = IupDialog (pc); /* criação do diálogo */ IupSetAttribute (d, IUP_K_F1, "exibe_caixa"); /* Defines F1 to display the box */ IupSetAttribute (d, IUP_K_F2, "retira_caixa"); /* Defines F2 to hide the box */ /* Associates functions to the actions */ IupSetFunction("exibe_caixa",(Icallback)exibe); IupSetFunction("retira_caixa",(Icallback)retira); IupShow(d); /* Shows the dialog */ IupMainLoop(); /* Interacts with user */ IupClose(); }