Jump to content
Sign in to follow this  
alleycat

How to attach eventhandlers to a dialog?

Recommended Posts

I would like to attach eventhandlers to a dialog, not a display.

For displays I use:

(findDisplay 46) displayAddEventHandler ["MouseButtonDown", "_this execVM script.sqf'"];	

which fires a script when the left mouse is pressed. But how to do that for a dialog?

https://resources.bisimulations.com/w/index.php?title=ctrlAddEventHandler

This looks useful but I do not know how to reference the control it should point to.

How would I fix that?

Share this post


Link to post
Share on other sites

You can't add a MouseButtonDown EH to a display, only a control. Little confused because a dialog is a display.

Share this post


Link to post
Share on other sites

Not sure what you mean.


(findDisplay 46) displayAddEventHandler ["MouseButtonDown", "_this execVM script.sqf'"];

This will fire the script whenever the player presses the mouse in regular first person (which is display 46). However I would like to have that functionality in a dialog (mouse moving around on screen + buttons to click are present).

disableSerialization;
CreateDialog "cat_ui_corpse"; 
ctrlSetText [1001, "text"];
;

This will display a dialog with mouse control and some buttons. However how to place an evenhandler for mouse clicks into this?

(_display displayCtrl 5000) ctrlSetEventHandler ["MouseButtonDown", "_this execVM script.sqf'];

Does not work

Edited by alleycat

Share this post


Link to post
Share on other sites

Huh, must be new in A3 or something Apparently the Biki page on ctrlEventHandlers is just showing information from Armed Assault. Well since it looks like you're using a custom display, just put:

onMouseButtonDown = "_this execVM 'script.sqf'";

into the display class.

You can also do things like use onLoad to add EH's or save the display into a variable for later use. However findDisplay should work fine if using createDialog, so long as your display has a hardcoded idd.

Edited by SilentSpike

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×