Makebutton "OnAnyEvent" = func

Feature requests for future versions of Hollywood can be voiced here

Makebutton "OnAnyEvent" = func

Postby Bugala » Sun Aug 27, 2017 4:14 pm

Now that I am changing functions activated by button calls on the fly, I am currently thinking the cleanest way to do this is:

Code: Select all
function MyButtonActionFunction(msg)
switch msg.action
           case "OnMouseDown":
           case "OnRightMouseDown":

And this is what i basically use on any button, that regardless what event triggered, it is always going to that one and same function dedicated for that buttons action events so it can call the appropriate function that i can change on the fly.

Therefore, it would be nice to have on that Makebuttons event part "OnAnyEvent" possibility, for now that I am always calling the same function, it is slightly annoying to:
Code: Select all
MakeButton(NIL, #SIMPLEBUTTON, 100, 100, 200, 200 {OnMouseDown = samefunc, OnRightMouseDown = samefunc, OnMiddleMouseDown = samefunc, OnMouseUp = samefunc, OnRightMouseUp = samefunc...})

when it could be done:
Code: Select all
MakeButton(NIL, #SIMPLEBUTTON, 100, 100, 200, 200 {OnAnyEvent = samefunc})

Although the drawback is that this MyActionButtonFunc would be called on every possible event, I dont think that is such a big deal, since if all my Function does is to check which action it is and then switch to corresponding action to execute corresponding function meant for it, I dont think it would really take that much resources even it would everytime come and execute that even when unnecessary.
Posts: 645
Joined: Sun Feb 14, 2010 8:11 pm

Re: Makebutton "OnAnyEvent" = func

Postby Allanon » Wed Nov 01, 2017 7:03 pm

If you need such feature you can write your custom MakeButton code, for example :

Code: Select all
Function MakeButton2(id, type, x, y, w, h, callback)
  Local id = MakeButton(id, type, x, y, w, h, {OnMouseDown = callback, OnRightMouseDown = callback, OnMiddleMouseDown = callback, OnMouseUp = callback, OnRightMouseUp = callback...})

And you are done :)
User avatar
Posts: 420
Joined: Sun Feb 14, 2010 8:53 pm
Location: Italy

Re: Makebutton "OnAnyEvent" = func

Postby Bugala » Wed Nov 01, 2017 9:55 pm

Funny how simplest of solutions sometimes just dont come to mind. Thanks from that solution, will help keep the code cleaner.
Posts: 645
Joined: Sun Feb 14, 2010 8:11 pm

Return to Wishlist

Who is online

Users browsing this forum: No registered users and 1 guest