Jump to content
gc8

onMouseEnter EH

Recommended Posts

Hi 

 I was trying to get the MouseEnter EH to work on control but it doesn't trigger. mousemoving EH works though.


Here's my code:

 

_id = _soldiersList ctrlAddEventHandler ["MouseEnter",
{
 params ["_ctrl"];
 
 systemchat "HOVER";
}];
_id = _soldiersList ctrlAddEventHandler ["MouseExit",
{
 params ["_ctrl"];

 systemchat "HOVER out";
}];

 

Anyone know whats wrong?

 

thx!

Share this post


Link to post
Share on other sites
STATIC: No
BUTTON: Yes
SLIDER: Yes (Enter delayed, Exit only when focused)
COMBO: No
LISTBOX: No
TOOLBOX: Yes
CHECKBOXES: Yes
PROGRESS: No
HTML: No
ACTIVETEXT: Yes (on the letters)
TREE: Yes
STRUCTURED_TEXT: Yes
CONTROLS_GROUP: No
SHORTCUTBUTTON: Yes
XLISTBOX: Yes
XSLIDER: Yes/No (delayed, exit only when dragging)
MAP_MAIN: No

 

Just tested the EHs on some control types and these are the results. Seems kind of random to me. In the cases of the SLIDER and XSLIDER the EH were really wonky.

  • Thanks 1

Share this post


Link to post
Share on other sites

@7erra Thanks, that's good to know! I was also thinking it might only work on buttons and such... so I take STATIC means backgrounds too. Not very useful EH then lol

 

Share this post


Link to post
Share on other sites

Apparently you can use a STRUCTURED_TEXT control as background and assign the EH to this control though

Share this post


Link to post
Share on other sites
16 hours ago, 7erra said:

Apparently you can use a STRUCTURED_TEXT control as background and assign the EH to this control though

 

I don't know about that, it's a bit too hacky solution for me. So I'll think about workaround or something... :sigh:

thx though!

Share this post


Link to post
Share on other sites
22 hours ago, gc8 said:

So I'll think about workaround

MouseMoving EH combined with getMousePosition and inArea commands.

Spoiler

_null = [] spawn {
	disableSerialization;
	createDialog "RscDisplayCommon";
	waitUntil{ !isNil{ uiNamespace getVariable "RscDisplayCommon" } };
	_display = uiNamespace getVariable "RscDisplayCommon";

	_ctrl = _display ctrlCreate[ "ctrlListbox", 10001 ];
	_ctrl ctrlSetPosition[ 0, 0, 1, 1 ];
	_ctrl ctrlCommit 0;

	_txt = _display ctrlCreate[ "ctrlStatic", 10002 ];
	_txt ctrlSetPosition[ 0.4, 0.48, 0.2, 0.02 ];
	_txt ctrlCommit 0;

	_display displayAddEventHandler[ "MouseMoving", {
		params[ "_display" ];

		_ctrl = _display displayCtrl 10001;
		ctrlPosition _ctrl params[ "_x", "_y", "_w", "_h" ];
		_w = _w / 2;
		_h = _h / 2;
		_isMouseOver = getMousePosition inArea[ [ _x + _w, _y + _h ], _w, _h, 0, true ];

		_wasMouseOver = _display getVariable[ "TAG_mouseEntered", false ];

		_txt = _display displayCtrl 10002;
		if ( !_wasMouseOver && _isMouseOver ) then {
			_txt ctrlSetText "Entered";
		};
		if ( _wasMouseOver && !_isMouseOver ) then {
			_txt ctrlSetText "Exited";
		};

		_display setVariable[ "TAG_mouseEntered", _isMouseOver ];
	}];
};

 

 

Edited by Larrow
Added example
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

@Larrow thanks! That is a nice solution, using it in my project (works good!).:rthumb:

  • Like 1

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

×