MakeButton

Report any Hollywood bugs here
Post Reply
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

MakeButton

Post by djrikki »

Just an observation, I wasn't expecting this behaviour. Is this a bug?

MakeButton(#IMAGERESIZE, #SIMPLEBUTTON, 177,38,124,34, evtfunc, p_openimageResizeDisplay)

Look at the Userdata field, I am using a Function here. This will be called via msg.userdata in a Switch....Case conditional structure as expected.

Now take a look at this.

MakeButton(#IMAGERESIZE, #SIMPLEBUTTON, 177,38,124,34, evtfunc, p_openimageResizeDisplay(selected$[0])

This time I add parameters into the function set as Userdata.

Now when I run the program, the interpreter calls p_openimageResizeDisplay(selected$[0]) with parameters WHEN THE BUTTON IS CREATED and not as the result of callback.

Also try this:

MakeButton(#IMAGERESIZE, #SIMPLEBUTTON, 177,38,124,34, evtfunc, DebugPrint("here"))

The interpreter will again create the button and launch the userdata straightaway.

Therefore it is not currently possible to set a function that require parameters as userdata.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
User avatar
Allanon
Posts: 742
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: MakeButton

Post by Allanon »

Try this quick example:

Code: Select all

Function HandleLMB(msg)
   ; Execute your custom function
   msg.userdata.func(msg.userdata.params[0])
EndFunction

...
my_userdata = { func = DebugPrint, params = { "HELLO!" } }
MakeButton( ...., { OnMouseDown = HandleLMB }, my_userdata)
...
This should work
----------------------------
[Allanon] Fabio Falcucci | GitHub (leaving) | Gitea (my new house) | My Patreon page | All my links
User avatar
airsoftsoftwair
Posts: 5871
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: MakeButton

Post by airsoftsoftwair »

@djrikki: What you experience is completely normal behaviour and not a bug. Check the documentation on functions in the Hollywood doc.
Post Reply