Jump to content
Sign in to follow this  
Prodavec

Cannot disable ENTER key whie creating the marker

Recommended Posts

The first

(findDisplay 46) displayAddEventHandler ["keyDown", "if (((_this select 1) == 28) && visibleMap) then {hint 'ENTER pressed'; true}"];

doesn't work if you Double Click on the map and quckly (very quickly) hit ENTER. You'll see "ENTER pressed" hint but ENTER will work like it wasn't disabled. Why?

(_this select 0) tells me that event has been recieved from display #46, not #54 (map marker) for some reasons. If I press ENTER key after double clicking on the map, I shouldn't see any messages, because no EH attached to display #54 but I can see.

For example

(findDisplay 46) displayAddEventHandler ["keyDown", "if (((_this select 1) == 53) && visibleMap) then {hint 'SLASH pressed'; true}"];

works fine. It disables the "/" key on the Map Screen.

The second strange thing, keyDown event is fired earlier than mouseButtonDblClick event. Simple code below demonstrates that behaviour:

(findDisplay 46) displayAddEventHandler ["keyDown", "player sideChat 'Key pressed!'"];
((findDisplay 12) displayCtrl 51) ctrlSetEventHandler ["mouseButtonDown", "player sideChat 'Double Click on the map!'"];

If you VERY quickly hit Double LBM and then ENTER you'll get

Key pressed!

Double Click on the map!

Why?

It should be

Double Click on the map!

Key pressed!

I need to completly disable ENTER key on the Map Screen and I need script-based solution, with no addons (for some reasons I cant use addons in my situation).

Edited by Prodavec

Share this post


Link to post
Share on other sites

So your saying your getting errors when creating a marker and then hitting enter?

but what Im missing is whats the point of hitting enter when you have to then go back

and edit the marker names and other info if any for it.

If you VERY quickly hit Double LBM and then ENTER you'll get

Key pressed!

Double Click on the map!

Why?

It should be

Double Click on the map!

Key pressed!

When I put a marker down thats it I dont get messages, I edit them right away and am done.

Idk but seems to me your creating drama about something that works fine, I never had any issues with markers and I use them all the time,

other then if the marker is big then trying to find the center is a pain when put together with other markers.

Share this post


Link to post
Share on other sites

What is your intention? to disable marker creation?

Share this post


Link to post
Share on other sites
So your saying your getting errors when creating a marker and then hitting enter?

Nope, I'm not getting errors. I can't disable ENTER key on the map screen because of some strange behaviour of the keyDown Event Handler, it's only related to the ENTER key.

PvPscene

I'm working on the script which adds nickname to the created map marker. For example you want to place marker with text: "This is our location" and after pressing ENTER marker becames "Prodavec: This is our location". And that script must work with no downloadable addons.

I found next algorythm to approach my goal (I used it to disable "Respawn" key, and Valhalla by WINSE used it too):

1. Add event handler mouseButtonDblClick to the map control on mission init.

2. When user double click on the map, mouseButtonDblClick EH begins to search marker display (it's Display #54). Searching loop works until Display #54 will be found, also it has timeout, just for case, 2 seconds for search, if not found => exit. Loop is under SPAWN command, so it's in scheduled script environment and may be delayed if mission has a lot of other running script in parallel (see below).

3. After searching Display #54, loop using exitWith adds keyUp EH to the Display #54. That event handler can process user keys when he types in the text field of the map marker.

4. When user presses ENTER, keyUp EH gets Control #101 of the Display #54 and changes control's text to the

Text = <player name> + Text

It works fine and doesn't require addon to change RscDisplayInsertMarker class.

But there's a problem related to SPAWN command: if you hit ENTER very quickly after Double Click, the searching loop will not find Displat #54 (the marker). I fully understand mechanics why it happens and my solution is to disable ENTER key after Double Clicking on the map for few milliseconds.

mouseButtonDblClick EH disables ENTER key, searching loop enables ENTER when Display #54 will be found and KeyUp EH installed, or by timeout (just for case).

I found that if you presses ENTER very-very quickly the "keyDown" event is recieved from Display #46 (not Display #54), so I just added new EH to the Display #46 with simple code: if (key == ENTER && disableEnterKey) {... Ignore ENTER ...} else {... process ENTER normally...}

But ENTER still works. Maybe Display #54 and Display #46 firing "keyDown" event at the same time, is it possible?

The second thing: keyDown EH is being fired BEFORE mouseButtonDblClick fired. I don't understand why? So even you will set disableEnterKey = true via mouseButtonDblClick (non-scheduled part) the keyDown event under else {...process ENTER normally...} scope will be processed anyway.

How do I disable ENTER key or may be you have better solution?

Thank you.

Edited by Prodavec

Share this post


Link to post
Share on other sites

Without the full (current) code I may get a wrong idea, but here are my thoughts:

# Why do you add DEH to main display and not to map display?

# My approach would be to *replace the map display with a scripted one. See:

http://forums.bistudio.com/showthread.php?110378-PvPscene-Tweaks&p=1807292&viewfull=1#post1807292

With scripted markers and catching player keyboard input, one should be able to replicate the current map marker completely,

and more important add more features like yours. Its more effort, but not too much I think and should be more/fully reliable.

Edited by .kju [PvPscene]

Share this post


Link to post
Share on other sites

Thank you for helping me guys.

PvPscene

Thank you, I think you're right, I should completly rebuild map marker (and create new one, scripted version), it's more reliable and protect against programms like AutoHotkey.

Topic may be closed, credits will be given in my script file / mission header.

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  

×