New topic: 

CTRL+A not working

<http://forums.realsoftware.com/viewtopic.php?t=39787>

         Page 1 of 1
   [ 7 posts ]                 Previous topic | Next topic          Author  
Message        reets          Post subject: CTRL+A not workingPosted: Mon Jul 
11, 2011 7:49 am                                 
Joined: Sun Nov 18, 2007 11:19 am
Posts: 123
Location: New Brunswick, Canada                The follow code seems to work 
fine when running in the IDE on Win 7 but when compiled and running on Win XP 
it doesn't work at all. Am i doing something wrong here?

Code:  if Keyboard.AsyncControlKey and key = "a" or key = "A" then
  me.SelectAll
  Return True
  end if   
                             Top                timhare          Post subject: 
Re: CTRL+A not workingPosted: Mon Jul 11, 2011 10:54 am                         
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 9982
Location: Portland, OR  USA                Where is the code located?  If it's 
in a KeyDown event, it shouldn't work at all.  I suspect the control is 
intercepting the keystroke on Win7 and your code isn't even coming into play.

There are 2 problems:
Ctrl-A generates a Chr(1), not a "a" character.
In KeyDown events, you shouldn't use the Async versions of the Keyboard 
properties.   
                             Top                reets          Post subject: 
Re: CTRL+A not workingPosted: Mon Jul 11, 2011 11:05 am                         
        
Joined: Sun Nov 18, 2007 11:19 am
Posts: 123
Location: New Brunswick, Canada                Ok. So i should be checking for 
a key = chr(1) in the keyup event? And how do you test for CTRL key being 
pressed if not with Async?

The code is in the KeyDown even and is not being reached after adding a msgbox 
and it's not coming up  Putting the same code in the KeyUp even does produce a 
msgbox    
                             Top                timhare          Post subject: 
Re: CTRL+A not workingPosted: Mon Jul 11, 2011 11:22 am                         
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 9982
Location: Portland, OR  USA                reets wrote:Ok. So i should be 
checking for a key = chr(1) in the keyup event? 

Correct.

Quote:And how do you test for CTRL key being pressed if not with Async?
Keyboard.ControlKey contains the state of the key when the event was generated, 
ie., when the key was pressed.
Keyboard.AsyncControlKey contains the state of the key when the code is 
executed, ie., now.  Things may have changed if you have a fast typist.

Note: I have not tested the correctness of that information for KeyUp, only 
KeyDown.  But I believe it is the same.   
                             Top                reets          Post subject: 
Re: CTRL+A not workingPosted: Mon Jul 11, 2011 11:51 am                         
        
Joined: Sun Nov 18, 2007 11:19 am
Posts: 123
Location: New Brunswick, Canada                So ControlKey does work great 
but doing

Code:if key = chr(1) then me.selectall

in the KeyUp event, it never triggers. I'll roll out the other code and see if 
it works on Win XP.   
                             Top                timhare          Post subject: 
Re: CTRL+A not workingPosted: Mon Jul 11, 2011 12:16 pm                         
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 9982
Location: Portland, OR  USA                Stupid question, but are you 
returning True from KeyDown?  Otherwise KeyUp never fires.   
                             Top                reets          Post subject: 
Re: CTRL+A not workingPosted: Mon Jul 11, 2011 12:20 pm                         
        
Joined: Sun Nov 18, 2007 11:19 am
Posts: 123
Location: New Brunswick, Canada                Good question, since i didn't 
know that  I'm not returning it openly. I do have a Return True when you press 
enter but that's it and it's inside the IF statement.

Update:
Just tested the new code on Win XP and it worked! Thanks 

Code:if Keyboard.ControlKey and (key = "a" or key = "A") then me.selectall   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 7 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to