realbasic-nug
[Top] [All Lists]

Re: Toggle checkbox using return key

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Toggle checkbox using return key
From: Charles Yeomans <charles at declareSub dot com>
Date: Thu, 30 Aug 2007 18:43:31 -0400
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <039c01c7eb52$42467d70$23fabf44 at CPQLaptop>
On Aug 30, 2007, at 6:08 PM, Rob wrote:

> Hi,
> I'm trying to allow users to toggle a checkbox value by tabbing to the
> checkbox and hitting the return key. The problem I'm having is that  
> chr(13)
> seems to fire twice, once when the user hits the key, and again  
> when the
> value is changed. Is there another way to accomplish this?
> Here's the code I'm using in the KeyDown event:
>
>  if key = chr(13) then
>     if me.Value=False then
>       me.Value=True
>     else
>       me.Value=False
>     end
>   End If


First, you could rewrite this as follows.

if (key = Chr(13)) then
   me.Value = not me.Value
end if

I'm not sure what you mean by "chr(13) seems to fire twice", but you  
might try returning true from the KeyDown event handler.  Since  
Checkboxes don't get KeyDown events in Mac OS, I'm just guessing.

If this does not work, then you can write a Checkbox subclass in  
which the Action event handler is called exactly when you want it to  
be called.

Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>