Antonio, I'm already doing the callback in a custom way using IupLoopStepWait(). The following is how I'm now doing my .50 cent callbacks now. My goal now that I have multi-threading working in the console interpreter and not only the web server, a direct callback to the SB call function embeddng API. (like what Charles is doing with DLLC but Windows only) John *** C Interface *** besFUNCTION(PuiSetCallback) Ihandle *ih; const char *name; char *class_name;
besARGUMENTS("pz") &ih, &name besARGEND class_name = IupGetClassName(ih); if (strcmp(class_name, "dialog") == 0) { IupSetCallback(ih, name, (Icallback)&WinEvent); } else if (strcmp(class_name, "button") == 0) { IupSetCallback(ih, name, (Icallback)&BtnEvent); } else if (strcmp(class_name, "list") == 0) { IupSetCallback(ih, name, (Icallback)&ListEvent); } else { IupSetCallback(ih, name, (Icallback)&Event); } besRETURN_STRING(class_name); besEND *** iup.inc *** SUB MainLoop ExitLoop = 0 REPEAT __LoopStepWait() this_event = __GetEvent() IF this_event <> undef THEN IF this_event = event{this_event}[0] THEN ICALL(event{this_event}[1]) END IF END IF UNTIL ExitLoop END SUB FUNCTION SetCallback(ih, aname, faddr) event{ih}[0] = ih event{ih}[1] = faddr event{ih}[2] = aname SetCallback = __SetCallback(ih, aname) END FUNCTION *** Example Use *** ' IUP Button / Event Example IMPORT iup.inc SUB Btn1_clicked PRINT "BUTTON 1 Event\n" END SUB SUB Btn2_clicked PRINT "BUTTON 2 Event\n" END SUB SUB Btn3_clicked PRINT "BUTTON 3 Event\n" END SUB SUB Win_exit Iup::ExitLoop = TRUE END SUB Iup::Open() win = Iup::Create("dialog") Iup::SetAttributes(win, "TITLE=\"Test Dialog\", SIZE=300x") horzbox = Iup::Create("hbox") Iup::SetAttributes(horzbox, "GAP=5") btn1 = Iup::Create("button") Iup::SetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL") btn2 = Iup::Create("button") Iup::SetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL") btn3 = Iup::Create("button") Iup::SetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL") Iup::Append(horzbox, btn1) Iup::Append(horzbox, btn2) Iup::Append(horzbox, btn3) Iup::Append(win, horzbox) Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit())) Iup::SetCallback(btn1,"ACTION",ADDRESS(Btn1_clicked())) Iup::SetCallback(btn2,"ACTION",ADDRESS(Btn2_clicked())) Iup::SetCallback(btn3,"ACTION",ADDRESS(Btn3_clicked())) Iup::Show(win) Iup::MainLoop() Iup::Close() jrs@jrs-laptop:~/sb/examples/iup$ scriba 3buttons.sb BUTTON 1 Event BUTTON 2 Event BUTTON 3 Event jrs@jrs-laptop:~/sb/examples/iup$ On Wed, 2016-11-30 at 10:05 -0200, Antonio Scuri wrote: > To an event, no. To an element you can set any custom attributes. > John, I think you should rethink the callbacks in Script Basic. > Let's talk again about the possibilities. > I think that in basic the user could call a custom function > IupSetCallback (not the original) that receives a function in basic. > Can we retrieve a reference to that function in C? So we can store it > and call it later. > Best, > Scuri >
------------------------------------------------------------------------------
_______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users