Re: IUP 3.31 Wrapper

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...
Icy_Viking said...

I can't figure why this example isn't working.

As for the example a brief console window shows up then goes away. My guess is I need a more Euphoria way of using the callback or I'm missing something?

You need to translate the rest of that example as well: https://www.tecgraf.puc-rio.br/iup/en/7gui/counter.c

Without an IupMainLoop() after an IupShow[XY](), no IUP program would ever do anything other than terminate immediately.

As-is, I would expect that IupGetDialogChild() call to either crash or return NULL since there is no interface element with a "NAME" of "TEXT",
and if it does not crash, simply g/set the meaningless "VALUE" attribute in the global environment, which wouldn't do anything useful/visible.

PS: there is also a "VAULE" typo in your translation, and you will probably need to change "object self" to "atom self" otherwise call_back() on it will complain.

Alright, I fixed the typo and re-wrote the program in Euphoria. However nothing still shows up.

--Counter example 
 
include std/ffi.e 
 
include iup.e 
 
public function btn_count_cb() 
	atom self = 0 
	object text = IupGetDialogChild(self,"TEXT") 
	atom val = IupGetInt(text,"VALUE") 
	IupSetInt(text,"VALUE",val+1) 
	 
	return IUP_DEFAULT 
end function 
 
atom id = routine_id("btn_count_cb") 
atom cb = call_back(id) 
 
procedure Main() 
 
	IupOpen(NULL,NULL) 
	 
	atom button = IupButton("Count","") 
	IupSetAttribute(button,"SIZE","60") 
	atom text = IupText("") 
	IupSetAttribute(text,"SIZE","60") 
	IupSetAttribute(text,"NAME","TEXT") 
	IupSetAttribute(text,"READONLY","YES") 
	atom hbox = IupHbox(text,button) 
	IupSetAttribute(hbox,"MARGIN","10x10") 
	IupSetAttribute(hbox,"GAP","10") 
	atom dlg = IupDialog(hbox) 
	IupSetAttribute(dlg,"TITLE","Counter") 
	 
	IupSetInt(text,"VALUE",0) 
	 
	IupSetCallback(button,"ACTION",cb) 
	 
	IupShowXY(dlg,IUP_CENTER,IUP_CENTER) 
	 
	IupMainLoop() 
	 
	IupClose() 
end procedure 
 
Main() 

This very simple example works just fine.

--Hello World Example 
include std/ffi.e --for NULL 
 
include iup.e 
 
public procedure Main() 
 
	IupOpen(NULL,NULL) 
	 
	IupMessage("Hello World","Hello World from IUP") 
	 
	IupClose() 
	 
end procedure 
 
Main() 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu