Jump to content
drunken officer

Help with Dialog, when mouse over picture

Recommended Posts

Hello guys

 

I've add 2 displayeventhandlers (keydown, keyup) to my mission. If you press down, you open and hold a dialog. In this dialog, i've 3 elements (pictures)

Is there a way to activate a script, when the mouse is pointing over picture AND the dialog is closing / close ?

At the moment, i use a button behind the pictures and can click on it. This works, but i dont like it with the button.

 

Exampale:

Mouse at picture 1: Hint "Your mouse was over picture 1"

Mouse at picture 2: Hint "You mouse was over picture 2"

Mouse at picture 3: Hint "You mouse was over picture 3"

 

 

 

Here the code for the displayEventhandler

DOF_onKeyDown =
{
   private "_key";
    _key = _this select 1;
    if (_key == 219 && (cursorTarget distance player <1.4))  then //L Win
    {
         if (isNull (findDisplay 47110) && !(player getVariable "DOF_isBusy" ) then
         {
             createDialog "Dialog_main";
         }
        
    };
   
};


DOF_onKeyup =
{
     private "_key";
     _key = _this select 1;
     if (_key == 219 && !isNull (findDisplay 47110) ) then { closeDialog 47110 };

};
waitUntil {!isNull (findDisplay 46)};
(findDisplay 46) displayAddEventHandler ["keyDown", "_this call DOF_onKeyDown"]; (findDisplay 46) displayAddEventHandler ["keyup", "_this call DOF_onKeyup"];

 

Some lines of Dialog

 


class Dialog_main
{
    idd = 47110;                        // is needed for displayEventhandler
    movingenable = false;

....

class controls

{

class RscPicture_1201: DOF_RscPicture
                {
                    idc = 1201;
                    text = "DOF_main\tex\UAV_act.paa";
                    x = 0.489687 * safezoneW + safezoneX;
                    y = 0.643 * safezoneH + safezoneY;
                    w = 0.0257812 * safezoneW;
                    h = 0.044 * safezoneH;


                };

....

};}

Share this post


Link to post
Share on other sites
#include "\a3\ui_f\hpp\definedikcodes.inc"

DOF_onKeyDown = {
	params[ "", "_keyCode" ];
	
	if (_keyCode isEqualTo DIK_LWIN && { !isNull cursorObject && { cursorObject distance player <1.4 }} ) then {
		 if (isNull (findDisplay 47110) && !(player getVariable "DOF_isBusy" ) then {
			 createDialog "Dialog_main";
		 };        
	};   
};

DOF_onKeyup = {
	 params[ "", "_keyCode" ];
	 
	 _display = findDisplay 47110;
	 
	 if ( !isNull _display && { _keyCode isEqualTo DIK_LWIN } ) then {
	 	_picturesIDCs = [ 1201 /*add pic ctrls here*/ ];
	 	_mousePos = getMousePosition;
	 	
	 	_mouseOverIDC = {
	 		ctrlPosition( _display displayCtrl _x ) params[ "_ctrlX", "_ctrlY", "_ctrlW", "_ctrlH" ];
	 		_center = [ _ctrlX + ( _ctrlW / 2 ), _ctrlY + ( _ctrlH / 2 ) ];
	 		if ( _mousePos inArea [ _center, _ctrlW / 2, _ctrlH / 2, 0, true ] ) exitWith { _x };
	 	}forEach _picturesIDCs;
	 	
	 	if !( isNil "_mouseOverIDC" ) then {
	 		hint format[ "Your mouse was over the picture with IDC = %1", _mouseOverIDC ];
	 		[ _mouseOverIDC ] call DOF_fnc_selectedPicture;
	 	};
	 	
	 	closeDialog 47110
	 };
};

waitUntil {!isNull call BIS_fnc_displayMission };
private _display = call BIS_fnc_displayMission;
_display displayAddEventHandler ["keyDown", DOF_onKeyDown ];
_display displayAddEventHandler ["keyup", DOF_onKeyup ];

 

Share this post


Link to post
Share on other sites

First of all: Thanks a lot man!

 

Generally it works. But there is a problem. The input is not correct, it is more right.

When I pointingthe middle one, i get the input of the left. When i pointing the right one, i get the input of the middle one. And when i pointing right side of the right pic (same distance as pic to pic) i get the input of the right picture

Share this post


Link to post
Share on other sites

Sorry typo because I didn't test it, as its something I have used a lot recently so just typed it out on the forum.

if ( _mousePos inArea [ _center, _ctrlW / 2, _ctrlH / 2, 0, true ] ) exitWith { _x };

Half the width and height, I had X and Y in there. Fixed previous post.

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

×