mIRC Home    About    Download    Register    News    Help

Print Thread
KEYDOWN for dialogs #167740 29/12/06 09:27 AM
Joined: Jul 2003
Posts: 25
Y
Yochai Offline OP
Ameglian cow
OP Offline
Ameglian cow
Y
Joined: Jul 2003
Posts: 25
Why isn't there a keydown event for dialogs ?
I think it would be pretty usefull to have a keydown event for dialogs as well as custom @windows.
I've encountered a few situations where I really neede to capture key events but couldn't, and then had to find ways to work around it.
Hmm, I hope it's not too difiicult, I'm sure it won't be too hard to make the On Keydown event apply to dialogs as well.

Re: KEYDOWN for dialogs [Re: Yochai] #167752 29/12/06 04:43 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
That would be nice to have built in. I think DCX might have that ability, but I don't see it from a quick look at the website.


Invision Support
#Invision on irc.irchighway.net
Re: KEYDOWN for dialogs [Re: Riamus2] #167763 30/12/06 02:06 AM
Joined: Jan 2003
Posts: 249
C
ClickHeRe Offline
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
There isn't because keydown is a per control event in windows. The keyboard is trapped by the control/window that has the focus. In dialogs, the dialog window never has the focus it's always one of its child controls.

That's why there is no on keydown for dialogs. The only way to achieve this would be to intercept all keydown events on each control to relay them back in some fashion to simulate the event.


Re: KEYDOWN for dialogs [Re: ClickHeRe] #167765 30/12/06 03:08 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
What about a special hidden control that is always in focus and capture keypresses? Not sure how well that would work, but it's a thought.


Invision Support
#Invision on irc.irchighway.net
Re: KEYDOWN for dialogs [Re: Riamus2] #167790 30/12/06 04:59 PM
Joined: Oct 2003
Posts: 313
S
Sais Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 313
Or have the child controls pass the keydown/up event up to their parent. That ought to be possible, but it is Windows, after all, so one can never be sure smile


Sais
Re: KEYDOWN for dialogs [Re: Riamus2] #167798 30/12/06 07:46 PM
Joined: Jan 2003
Posts: 249
C
ClickHeRe Offline
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
only one control can have focus at one time, so if you are typing in an edit, the other control will not receive keyboard events!

Re: KEYDOWN for dialogs [Re: Riamus2] #167799 30/12/06 07:50 PM
Joined: Apr 2004
Posts: 759
M
Mpdreamz Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
A control that always takes focus is highly annoying :p
Event bubbling could work indeed smile


$maybe
Re: KEYDOWN for dialogs [Re: ClickHeRe] #167806 30/12/06 09:11 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: ClickHeRe
only one control can have focus at one time, so if you are typing in an edit, the other control will not receive keyboard events!


If you're typing in an edit box, then it probably shouldn't track keyup/keydown either. I guess there may be a reason to do so in an edit box, but I'm thinking that most uses would be game related or similar and typing wouldn't be when you'd need to track the keypresses. I don't know... it was just a thought. I don't know much about how things work in the background, so I was just offering a suggestion. smile

It could be useful to have some kind of click once on a control to use (like you'd click a "window" -- whatever control you want to create that window with -- it will activate and then track keypresses). Then, if you click somewhere else, it will no longer track keypresses. For a game, this would let you run the game through this "window". It would be similar to how some activex and other scripting languages have you click on the window to use the control on a website. You could then have it also check the current mouse position only while it's over that "window" and when it's over it, you could have it draw in something such as crosshairs or a different mouse pointer. It's just too bad you can't hide the real mouse pointer. To point it out, I'm thinking of this window as if it were a picwin since that's where you could draw stuff. But it could really be various controls... even an icon. You just wouldn't be able to draw stuff in it that way.

Something like that could let you create a racing game inside a dialog and have arrow keys control your car as just one example. I know you can do this outside of a dialog. But inside a dialog could be nice if it was possible.


Invision Support
#Invision on irc.irchighway.net
Re: KEYDOWN for dialogs [Re: Yochai] #168011 02/01/07 06:22 PM
Joined: Oct 2004
Posts: 14
C
CakerX Offline
Pikka bird
Offline
Pikka bird
C
Joined: Oct 2004
Posts: 14
I just started using dialogs last week.

I agree with the OP, how about adding keydown/keyup, or even keypress to the "on dialog" event.

on *:dialog:name:keydown:id:{commands}

Re: KEYDOWN for dialogs [Re: CakerX] #168028 02/01/07 11:02 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
CakerX, if you want to check key presses in a specific ID, you can use DCX. I have DCX tracking the Enter key in an edit box to prevent having to use a hidden button to handle hitting Enter and having it move the edit line text into another control (in my case, a RichEdit control).

However, if you want keypresses for the DIALOG itself, that's where the problem comes in.


Invision Support
#Invision on irc.irchighway.net