ID:90730
 
Resolved
Key-up macros did not always trigger when changing window focus.
BYOND Version:462
Operating System:Windows 7 Ultimate
Web Browser:Firefox 3.5.7
Applies to:Dream Seeker
Status: Resolved (463)

This issue has been resolved.
Descriptive Problem Summary:
"When Dream Seeker loses focus to another application, keys that are held down are considered released and trigger the appropriate up-key macros"

This doesn't apply for the default input/alert/Options&Messages windows, or when you press on the little dreamseeker icon at the far left of the titlebar on interface windows.

Also, if you focus another interface window, the up-key only trigger once you stop pressing the key, as if the map window was still focused.

Numbered Steps to Reproduce Problem:

See Code Snippet

-Set up a macro for macrodown and macroup on the same keyboard key; check "when key is released" for "macroup".
-Click on alertme() and leave it on the side for now, focus the map window again.
-Hold down the macro for macrodown; while holding the macro, click on the alert window.
-macroup is supposed to be triggered since all pressed down keys are supposed to be released, but it won't. "Lewp()" will continue to run until you focus map window again and press respective macro key.

Code Snippet (if applicable) to Reproduce Problem:
mob
var
runproc
presseddown
verb
alertme()
alert("alert")
macrodown()
presseddown=1
Lewp()
macroup()
presseddown=0
proc
Lewp()
if(runproc)return
runproc=1
spawn while(1)
sleep(1)
if(!presseddown)
runproc=0
break
world<<rand(1,100)


Expected Results:
Up-key macros to trigger normally.

Actual Results:
They don't.

Does the problem occur:
Every time? Or how often? Yes.
In other games? n/a
In other user accounts? Yes.
On other computers? n/a

When does the problem NOT occur?
n/a

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
n/a

Workarounds:
n/a

Apparentally you want the arrow keys to also set the variable? You are only using verbs here, so, it will happen only when you click the verb, if you want to happen when you use the arrow keys, you need to look at client/North and the other such directions, right now it looks like it will keep moving North until you click the northarrow_up verb.

But something else you need to do is add in an if() so that they dont go clicking northarrow_down a lot to move insanely stupidly fast, unless u want that.
I obviously have macros set up to call those verbs when the key is pressed down and released.

And the code shown is an example...
Actually, your missing the whole thing, it seems that if you do hold the key, then click another window, then release it while that other window is active, then it does work, sort of, but keep reading.

There will be no popup when you do this anywhere, no message, etc... BUT, if you minimize the game, it will come up like it's supposed to.

That actually maybe only due to Windows though and how it works, as to why it appears at all though, when you minimize it. It probably in Windows, in my experience tells the window no keys are down, and doesn't allow you to send any keys to that window, as a security feature so you can't make a window do something that isn't even up to interact with in the normal ways.
mob
var
runproc
presseddown
verb
alertme()
alert("alert")
macrodown()
presseddown=1
Lewp()
macroup()
presseddown=0
proc
Lewp()
if(runproc)return
runproc=1
spawn while(1)
sleep(1)
if(!presseddown)
runproc=0
break
world<<rand(1,100)

Try it for yourself, no better way to explain.

-Set up a macro for macrodown and macroup on the same keyboard key; check "when key is released" for "macroup".
-Click on alertme() and leave it on the side for now, focus the map window again.
-Hold down the macro for macrodown; while holding the macro, click on the alert window.
-macroup is supposed to be triggered since all pressed down keys are supposed to be released, but it won't.

Everything works normally for other windows, just not alert/input.
I thought I just said I did this, and it worked just fine, just telling you what also happens too when doing this.
Your reply was rather confusing. Edited the OP, see if it happens with the other windows I mentioned.
Bug fix: Clicking on an alert() or input() box after it had already appeared could cause key-up macros not to fire.

(Ruben7, just as a reminder for future tracker/forum posts, please use more than one space for indentation when posting code in a <dm> block. Single-space indents are hard to read. Two works all right.)