Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 22 Aug 2009 13:29:01 +0200
Hi all,
is there a way to *query* an event handler (which was installed by InstallEventHandler()) in order to temporarly replace it?
For example an even on "OnMouseUp" should execute a default action, but at some point in the presenation, a different action should be executed maybe in addition to the default action.
It would be nice to get the eventFunction previously installed with InstallEventHandler and to replace it by a different event handler, which in turn, installs the old event handler again or even *calls* the old eventhandler at the end of its execution.
thanks!
Tom.
[22 Aug 2009] Question regarding InstallEventHandler()
- TheMartian
- Posts: 109
- Joined: Sun Feb 28, 2010 12:51 pm
[23 Aug 2009] Re: Question regarding InstallEventHandler()
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 23 Aug 2009 18:44:08 -0000
Hi
I presume you want to overload the standard functionality of your event function in specific circumstances with some different code.
One way to do that without actually changing the event function is to take advantage of LUAs ability to handle functions like variables and pass action to one of multiple alternatives of the same set of functions, each of which covers a particular condition. A small example...
You have to decide for yourself what constitutes condition1 and condition1, but they can be used to control which functionality you want active just now.
Of course you then need to activate your event handler (MyKeyEventHander)
This is a simple example. By adding parameters to the function call you can make it more flexible.
One of the tricks you can do is to activate another event type or disable an event. I have used this to create fake windows from layers that can be dragged and dropped by their (equally fake) menu bar as long as you keep the mouse down after clicking in the menu bar, but change functionality once you release the mouse button.
I hope this is useful and that there are no silly errors in my example, as I write this while not in the company of my amiga
regards Jesper
Hi
I presume you want to overload the standard functionality of your event function in specific circumstances with some different code.
One way to do that without actually changing the event function is to take advantage of LUAs ability to handle functions like variables and pass action to one of multiple alternatives of the same set of functions, each of which covers a particular condition. A small example...
Code: Select all
Function MyKeyEventHandler(msg)
switch msg.action
case "OnKeyDown"
if condition1
Myaction["DEFAULT_ACTION"]
if condition2
Myaction["MYOTHER_ACTION"]
EndSwitch
EndFunction
Code: Select all
// Now create a list of functions called Myaction={}
Myaction["DEFAULT_ACTION"] = function()
// Do what you need to do when you want the default action for OnKeyDown
EndFunction
Myaction["MYOTHER_ACTION"] = function()
// Do what you need to do when you want the specific action after the OnKeyDown event.
EndFunction
This is a simple example. By adding parameters to the function call you can make it more flexible.
One of the tricks you can do is to activate another event type or disable an event. I have used this to create fake windows from layers that can be dragged and dropped by their (equally fake) menu bar as long as you keep the mouse down after clicking in the menu bar, but change functionality once you release the mouse button.
I hope this is useful and that there are no silly errors in my example, as I write this while not in the company of my amiga
regards Jesper
[24 Aug 2009] Re: Question regarding InstallEventHandler()
Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 24 Aug 2009 09:10:03 +0200
So, this is another feature request for Hollywood 4.1 from my side
kind regards, Tom
Nice idea, but not exactly what I wanted to have. In your example here, you have to know the conditions in advance when your event handling should change. What I have in mind, is, to allow dynamically change the event handling. But for this, it would be necessary to get the current function from "InstallEventHandler()" in order to not only replace it, but also to install it later again.Code: Select all
Function MyKeyEventHandler(msg) switch msg.action case "OnKeyDown" if condition1 Myaction["DEFAULT_ACTION"] if condition2 Myaction["MYOTHER_ACTION"] EndSwitch EndFunction
So, this is another feature request for Hollywood 4.1 from my side
if you have full control over the code, this is indeed a nice way to handle it. But if you want to provide a template or library, which otheres could use (and then those users don't have a clue about the code of the library itself), the event handling has to be dynamically changeable such that, users are not too much restricted by your library.You have to decide for yourself what constitutes condition1 and condition1, but they can be used to control which functionality you want active just now. This is a simple example. By adding parameters to the function call you can make it more flexible.
It is useful! Thank you very much. And indeed, as long as the global table "Myaction" is known to everybody, you even can do the things I want to do because a table can be arbitrarily queried and changed. It's just not that convenient as if Hollywood itself allowed to get the currently set event handling function.One of the tricks you can do is to activate another event type or disable an event. I have used this to create fake windows from layers that can be dragged and dropped by their (equally fake) menu bar as long as you keep the mouse down after clicking in the menu bar, but change functionality once you release the mouse button.
I hope this is useful and that there are no silly errors in my example, as I write this while not in the company of my amiga![]()
kind regards, Tom
- airsoftsoftwair
- Posts: 5834
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
[24 Aug 2009] Re: Re: Question regarding InstallEventHandler()
Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 24 Aug 2009 13:03:22 +0200

Ok, sounds like a good idea. I'll add it to my listNice idea, but not exactly what I wanted to have. In your example here, you have to know the conditions in advance when your event handling should change. What I have in mind, is, to allow dynamically change the event handling. But for this, it would be necessary to get the current function from "InstallEventHandler()" in order to not only replace it, but also to install it later again.
So, this is another feature request for Hollywood 4.1 from my side![]()
- TheMartian
- Posts: 109
- Joined: Sun Feb 28, 2010 12:51 pm
[24 Aug 2009] Re: Question regarding InstallEventHandler()
Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 24 Aug 2009 19:05:57 -0000
By the way... Have you tried something like:
InstallEventHandler({OnKeyDown=p_MyEventHandler})
and then in response to, say, a mouse event you may have a function that issues a statement like:
InstallEventHandler({OnKeyDown=0}) to disable the first event handler.
As I indicated previously I used this to change the reaction to certain event types while the program was running based on other events.
Unfortunately I can't mail you the code as my old XEA1 seems to finally have given up after 7 years of stellar service. So perhaps it is SAM Flex time for me soon if any are available
regards Jesper
By the way... Have you tried something like:
InstallEventHandler({OnKeyDown=p_MyEventHandler})
and then in response to, say, a mouse event you may have a function that issues a statement like:
InstallEventHandler({OnKeyDown=0}) to disable the first event handler.
As I indicated previously I used this to change the reaction to certain event types while the program was running based on other events.
Unfortunately I can't mail you the code as my old XEA1 seems to finally have given up after 7 years of stellar service. So perhaps it is SAM Flex time for me soon if any are available
regards Jesper