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: "Rob" <rb at down2business dot com>
Date: Thu, 30 Aug 2007 18:47:55 -0400
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <039c01c7eb52$42467d70$23fabf44 at CPQLaptop> <F9BA6C78-5388-47C0-9851-CA195F5547AE at declareSub dot com>
Hi Charles,
Trying the options you suggested seems to produce the same result.
What I meant to say was that if a user tabs to a checkbox and hits return, 
the expression "if key = chr(13)" evaluates true 2 times for some reason. 
Basically, the checkbox value is changing twice.
Thanks,
Rob

----- Original Message ----- 
From: "Charles Yeomans" <charles at declareSub dot com>
To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
Sent: Thursday, August 30, 2007 6:43 PM
Subject: Re: Toggle checkbox using return key


>
> 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> 

_______________________________________________
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>