Re: Trapping the Option or Command keys

2009-07-28 Thread Sarah Reichelt
On Tue, Jul 28, 2009 at 10:08 PM, Bill Ziegler wrote:
> Thanks to all for your advice.
> I was going to check the state of the keys with an On-Idle script but will
> try Sarah's suggestion instead.

Don't use idle!
It was OK in HyperCard's day, but with modern multi--tasking, an app
with an idle loop will tie up your processor and all the other apps
will hate it.

Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Trapping the Option or Command keys

2009-07-28 Thread Bill Ziegler

Thanks to all for your advice.
I was going to check the state of the keys with an On-Idle script but  
will try Sarah's suggestion instead.


Thanks again

BIll
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Trapping the Option or Command keys

2009-07-28 Thread SparkOut


Sarah Reichelt-2 wrote:
> 
> On Tue, Jul 28, 2009 at 8:52 AM,  wrote:
>> Sarah:
>>
>> Just curious. Do you use "command" instead of (good ol') "on"?
>>
> 
> "command" was introduced in 3.? (3.5 I think) and I am gradually
> training myself to use it.
> The idea is that system messages still use "on", so you have "on
> mouseUp", "on preOpenStack" etc.
> But your own handlers use "command" instead of "on" to make it clearer
> what's what.
> "function" remains unchanged.
> 
> However it's just a matter of style, I don't think either way is
> inherently more correct and as far as I know, RunRev is not going to
> make either one compulsory any time soon.
> 
> Cheers,
> Sarah
> 
"command" has been around since before I started with Rev (2.7) - in the
dictionary it says it was introduced in version 1.0!
When I first started I defined every "command handler" with "command" as I
couldn't clearly see what was meant by "on" but as I got exposed to the
language I got used to "on" and adopted it (as well as "command" - see
below).
I think one of the main significant things is that you can define a "private
command " but (from the docs) "Note: Although it is also possible
to use "on" when declaring a private handler this is not recommended as it
implies that the handler is a message sent when some event occurs. As
private handlers are not passed through the message path, this is incorrect
and can make the code harder to understand. Please see the on control
structure entry for more details."
It is really a matter of style, as Sarah says. I have sort of got a hazy
policy of using "on" for handlers where I'm expecting a message to be passed
up the path and handled "on" an event, and command (or private command) for
handlers which are more just modular procedures (eg setup defaults) and/or
like a function that doesn't return a value. I certainly don't get overly
picky about the choice.
-- 
View this message in context: 
http://www.nabble.com/Trapping-the-Option-or-Command-keys-tp24685348p24696836.html
Sent from the Revolution - User mailing list archive at Nabble.com.

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Trapping the Option or Command keys

2009-07-27 Thread Sarah Reichelt
On Tue, Jul 28, 2009 at 8:52 AM,  wrote:
> Sarah:
>
> Just curious. Do you use "command" instead of (good ol') "on"?
>

"command" was introduced in 3.? (3.5 I think) and I am gradually
training myself to use it.
The idea is that system messages still use "on", so you have "on
mouseUp", "on preOpenStack" etc.
But your own handlers use "command" instead of "on" to make it clearer
what's what.
"function" remains unchanged.

However it's just a matter of style, I don't think either way is
inherently more correct and as far as I know, RunRev is not going to
make either one compulsory any time soon.

Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Trapping the Option or Command keys

2009-07-27 Thread DunbarX
Sarah:

Just curious. Do you use "command" instead of (good ol') "on"?

Craig Newman


**
A Good Credit Score is 700 or Above. See yours in 
just 2 easy steps! 
(http://pr.atwola.com/promoclk/100126575x1221823322x1201398723/aol?redir=http://www.freecreditreport.com/pm/default.aspx?sc=668072&;
hmpgID=115&bcd=JulystepsfooterNO115)
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Trapping the Option or Command keys

2009-07-27 Thread Sarah Reichelt
> I'm re-writing a hypercard stack in which buttons performed different
> functions if the OptionKey or CommandKey were down. I need the title and
> icon to change on all the buttons when either modifier key is down. Looking
> back in the archives it seems like it was a problem only on Macs. Is there a
> command now that will let me do this? The simplified interface I'm trying to
> re-create will allow a button that is bordering a text field to either read
> the contents of bordering text field with text-to-speech, record the
> student's voice or play back the recorded voice.

As other's have noted, on a Mac, there is no way to detect the
modifier keys being pushed until another key is pushed too.
When I have needed to do this, I set up a polling loop that checks the
state of the modifiers regularly and alters the buttons accordingly
e.g.

command checkModKeys
   if the commandkey is down then
  set the label of btn "Action" to "Play"
   else if the optionkey is down then
  set the label of btn "Action" to "Record"
   else
  set the label of btn "Action" to "Speak"
   end if

   if the pendingmessages contains "checkModkey" is false then
  send "checkModKeys" to me in 20 ticks
   end if
end checkModKeys

All you have to remember then is to send the first checkModKeys when
the card/stack opens and to stop the pending messages when it closes.

I have found that this works well without placing much load on the processing.

Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Trapping the Option or Command keys

2009-07-27 Thread J. Landman Gay

Richmond Mathewson wrote:


2.  The only 'problem' as far as I recall is that on a Mac the COMMAND key
(with a stylised apple on it) does the work of the CONTROL key in 
Windows.


Actually there's a bigger problem. Neither Mac OS nor Mac OS X send any 
keydown information about the Command or Control keys until a second 
letter is typed (same for Shift and Option too.) Rev can't generate 
keydown or rawkeydown messages on those because the OS doesn't notify 
the engine anything has happened.


The only way to see if those keys are being depressed on a Mac is to 
pair it with another system message, such as mouseEnter. Once you get a 
system message triggered, you can check the state of the key inside that 
handler ("if the commandkey is down...", etc.) I suppose one could use a 
mousemove handler to check the state. That would fire repeatedly, which 
may slow things down a bit, but probably not too much.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Trapping the Option or Command keys

2009-07-27 Thread Richmond Mathewson

Bill Ziegler wrote:



I'm re-writing a hypercard stack in which buttons performed different 
functions if the OptionKey or CommandKey were down. I need the title 
and icon to change on all the buttons when either modifier key is 
down. Looking back in the archives it seems like it was a problem only 
on Macs. Is there a command now that will let me do this? The 
simplified interface I'm trying to re-create will allow a button that 
is bordering a text field to either read the contents of bordering 
text field with text-to-speech, record the student's voice or play 
back the recorded voice.


Thanks,

Bill Ziegler
___


1.  Download my "KeyDowner" stack:

http://mathewson.110mb.com/FILEZ/KEYDOWNER.rev.zip

play around with it on Mac and Win.

2.  The only 'problem' as far as I recall is that on a Mac the COMMAND key
(with a stylised apple on it) does the work of the CONTROL key in 
Windows.


   So DON'T have settings for both COMMAND and CONTROL keys.
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Trapping the Option or Command keys

2009-07-27 Thread Bill Ziegler



I'm re-writing a hypercard stack in which buttons performed different  
functions if the OptionKey or CommandKey were down. I need the title  
and icon to change on all the buttons when either modifier key is  
down. Looking back in the archives it seems like it was a problem only  
on Macs. Is there a command now that will let me do this? The  
simplified interface I'm trying to re-create will allow a button that  
is bordering a text field to either read the contents of bordering  
text field with text-to-speech, record the student's voice or play  
back the recorded voice.


Thanks,

Bill Ziegler
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution