Home   Help Search Login Register  

Author Topic: displaySetEventHandler  (Read 1514 times)

0 Members and 2 Guests are viewing this topic.

Offline Goullou

  • Members
  • *
displaySetEventHandler
« on: 20 Mar 2008, 10:56:35 »
Hi scripters !

I'm working around this command in order to launch code by pressing a key.
Actualy it seems the UI is associated to display channels and precisely to the display "46" for the keyboard events. The BIS viki is very poor in explainations about this domain.

For now i can execute code by this way:
Code: [Select]
(findDisplay 46) displaySetEventHandler ["KeyDown","<my_code_2_call_here>"]
If someone could tell what he knows about those:

1) Is there a table of all displays, which tell of what they're pointing on?

2) How to stop the command?
I found nothing equivalent to "removeEventHandler" like a classic addEventHandler.
As soon as the displaySetEventHandler is sent to the engine, it seems to remain active.

3) Is there a way to run several times the command?
It seems the engine understand only the last command received.
I was using the addon CMJ_Sightajusment which is already using this command and as soon as I start to load my script, my script works but the SightAdjustment is dead.

Any comment's welcome   :scratch:
Si vis pacem, para bellum.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: displaySetEventHandler
« Reply #1 on: 20 Mar 2008, 11:02:25 »
1 - To find a list of displays:
Code: [Select]
_maxdisptocheck = 100;
_msg = [];
for [{_i=0},{_i < _maxdisptocheck},{_i = _i +1}] do
{
   if (!isNull (findDisplay _i)) then
   {
      _msg = _msg + format["DSP: %1\n", _i];
   };
};
hint _msg

2 -
Code: [Select]
findDisplay 46) displaySetEventHandler ["KeyDown", ""]
3 - So far, only 1 at a time, and sadly there is no way to get the code handle of the "current" one when you overwrites with another, so you can get back to the previous functionality when you are done.

Offline Goullou

  • Members
  • *
Re: displaySetEventHandler
« Reply #2 on: 20 Mar 2008, 11:20:35 »
1 - To find a list of displays:
Code: [Select]
...{
      _msg = _msg + format["DSP: %1\n", _i];
   };...

Good idea, i guess it will return a list of existing (valid) displays. Now I would like to know what they do. :dunno:

Quote
so you can get back to the previous functionality
I think you mean "so you can't get back to the previous functionality" ...
Si vis pacem, para bellum.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: displaySetEventHandler
« Reply #3 on: 20 Mar 2008, 12:43:25 »
Yes, you cannot because you cannot get the previous handler, unless the previous one is yours too.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: displaySetEventHandler
« Reply #4 on: 20 Mar 2008, 12:56:09 »
If you are trying to attach the key handler to one of your own displays, then you should know what its number is anyway (its IDD number). If you want the handler always available, then using 46 is your best bet anyway - you can't "share" the key events any more than you can share init or fired event handlers in addon code (which is why we have the Extended Event Handlers addon). I have SPON_addKeyEventHandler and SPON_removeKeyEventHandler functions in SPON Core, which allows different scripts to add and remove different key events without interfering, but unless everyone uses it, it doesn't really help anyone except me (Several of my script releases use it)  ::)
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)