Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / escape release key not working

Author
Message
T4r4ntul4
14
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 12th Jan 2010 15:56
hi community, iam new in dbpro, and i like it so far.

iam busy making a program, but i get stuck in some code i writed:
see code:




so my intention was if i pressed the ESC key, i wanted to release the mouse, otherwise if i not press the ESC key, my mouse key is not released, which its good.

but and heres my question, why is it not working? i keep press the esc key and the release key is working, if i not press the esc key its not working... i dont get it.

so would anyone help me with this? thanx already.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Jan 2010 20:17
The Escape key is a system key used by DB to exit a program and might be interfering with what you want to do.

I'm no DBPro expert, but in DBC there's the Disable SystemKeys and Disable EscapeKey commands. Have you tried either of them elsewhere in your program?

TDK

T4r4ntul4
14
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 12th Jan 2010 23:12
yes i use disable escapekey once in the setup load. funny thing is when i press esc key my mouse is enabled, but the rest of the code seems not be executed...

so is my if then else statement correct?

thanx for helping me.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Jan 2010 08:05 Edited at: 13th Jan 2010 08:05
There's no need to have another IF statement if you use ELSE because if escapekey() = 1 the alternative is going to be zero anyway.



The below code is being seen but it doesn't pay attention to it because it checks for mouse coordinates outside of the Darkbasic window. Darkbasic won't ever force the mouse back to allow the user to use other windows.



T4r4ntul4
14
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 13th Jan 2010 13:54
well that cleared up grog.

but still i dont understand why if i press the ESC key, i can still look around... but thats not in my code.

why doesnt stay the variable of escapekey() in 1? it goes right back to 0 if i dont press the esc key...

so how do i change the code so if i press the escape key the variable is still 1..?
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 13th Jan 2010 15:30 Edited at: 19th Jan 2010 20:13
Might I suggest that using the escape key as a toggle for allowing camera movement and mouse placement is not a good idea? Why not use the space bar or return key? How is the person going to get out of your program?

Quote: "still i dont understand why if i press the ESC key, i can still look around"


It is in your code. You are looking at the status of the escape key on an ongoing basis. If you let go of the key, the value it returns is 0. To get it to do what (I think) you want, you would have to save the status of the escapekey to a variable. You could do it like this:


Hope this helps.

Click my sig to download TGC Heroes v0.94.

T4r4ntul4
14
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 13th Jan 2010 17:50
thanx LBFN,

that did the trick. i modified your code to my own needs, buts its working now.

Quote: "How is the person going to get out of your program?"


well thats my next step, if the user pressed esc, the mouse is released for doing other things. like clicking in a menu. then the user would click on exit, or resume or whatever. but thats what im working now on.

thnx all for helping me out.

Login to post a reply

Server time is: 2024-11-24 20:47:10
Your offset time is: 2024-11-24 20:47:10