Sure. I used HC a lot when I was a bit younger, 30+ years ago.@Fjord. But do you see how this can work?
Change button label by pressing the command key
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Change button label by pressing the command key
--
François
François
-
- VIP Livecode Opensource Backer
- Posts: 125
- Joined: Tue Apr 11, 2006 7:02 pm
- Location: Seattle, WA
- Contact:
Re: Change button label by pressing the command key
I would consider changing Richmond's fine code every so slightly to use on mouseMove and apply a flag (optional). You may not need the flag. It will depend on what you plan to do next. The mouseMove check may be enough.
Code: Select all
//script local
local sTrackCommandKey
on mouseMove
if the commandKey is down then
put true into sTrackCommandKey
set the label of btn "XYZ" to "CmdKey Down"
else
put false into sTrackCommandKey
set the label of btn "XYZ" to "CmdKey Up"
end if
end mouseMove
//somewhere in the handling of the popup
//you may set the flag to false as well
//as in... put false into sTrackCommandKey
Mark Talluto
--
Canela
design - develop - deploy: https://appli.io
Database and Cloud for LiveCode Developers: https://livecloud.io
Company: https://canelasoftware.com
--
Canela
design - develop - deploy: https://appli.io
Database and Cloud for LiveCode Developers: https://livecloud.io
Company: https://canelasoftware.com
Re: Change button label by pressing the command key
@mtalluto: I do not really understand; what's the mouse got to do with the problem I stated at the start of this thread?
--
François
François
-
- Livecode Opensource Backer
- Posts: 9364
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Change button label by pressing the command key
Not much.
AND I, for one, cannot see what the 'sweat' is about using IDLE, as, for the sake of argument, even my maist manky Linux box has half a Gig of RAM.
AND I, for one, cannot see what the 'sweat' is about using IDLE, as, for the sake of argument, even my maist manky Linux box has half a Gig of RAM.
-
- VIP Livecode Opensource Backer
- Posts: 9656
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Change button label by pressing the command key
Richmond.
It isn't RAM, it is processor overhead. "Idle" messages are sent constantly at the IdleTicks rate. If they are not trapped, they pass relatively unseen through the system. But if they are trapped, even if the handler itself never fires, something like:
the system notices, and time is taken to see what is going on in that handler. This may impact processor-intense processes.
So idle is there, you just have to be aware of its ramifications.
Craig
It isn't RAM, it is processor overhead. "Idle" messages are sent constantly at the IdleTicks rate. If they are not trapped, they pass relatively unseen through the system. But if they are trapped, even if the handler itself never fires, something like:
Code: Select all
on idle
if the sun has already burned out then..
So idle is there, you just have to be aware of its ramifications.
Craig
Last edited by dunbarx on Sat Jun 04, 2022 10:06 pm, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 9364
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Change button label by pressing the command key
Well, as one has a SHIFT, an ALT/OPTION key, and a CTRL key, as well as whole slewThis may impact processor-intense processes.
of Function keys available to one with Macintosh there should not be any real reason to
have to muck around with the COMMAND key at all.
Re: Change button label by pressing the command key
@richmond62: sorry, I disagree.
1º shift and option have the same problem as the command key: you can’t get the fact that they are pressed without pressing another key (AFAIK)
2° function keys: I don’t know how to use these but that’s drifting from my original post.
All I was thinking of in my original post was, having two variants of the same script in the same btn, one to act on a single cd, one to act on all cds. Basically, I can have 2 different btns; I only wanted to save space on the cd.
1º shift and option have the same problem as the command key: you can’t get the fact that they are pressed without pressing another key (AFAIK)
2° function keys: I don’t know how to use these but that’s drifting from my original post.
All I was thinking of in my original post was, having two variants of the same script in the same btn, one to act on a single cd, one to act on all cds. Basically, I can have 2 different btns; I only wanted to save space on the cd.
--
François
François
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Change button label by pressing the command key
The mouseMove solution is good, but, though it's more efficient than idle, unless the trigger action is dependent on the mouse moving it may be possible that it won't trigger when needed.
Idle is less efficient, but probably not prohibitively so. Changing a button label is a small thing computationally, and the unused messages require so little CPU they probably aren't noticeable, and perhaps not even easily measurable on sufficiently fast systems.
The bigger challenge here seems less a technical concern in the messaging as much as a usability concern with having to remember a hidden option and also the means of revealing that option.
We spend so much time making our own software it's easy to forget how much time users spend with software that isn't ours. So being as gentle as possible with cognitive load goes a long way toward user satisfaction; users are busy, often distracted, and have to deal with a lot of systems all day that demand a lot of their attention.
Having both actions visible as separate buttons lets the user know there are two actions, without having to remember anything.
If available space is so critically limited it just isn't practical to display both action buttons at once, two options that come to mind are:
- Consider icons instead of labels for the buttons (if such images convey the action clearly).
- Consider putting both labels in a pulldown Action menu, where you could also add any other functionality you might think of later on.
But of course these notions are from someone who knows neither the UI nor the use case, so your good judgement with your hands-on knowledge is the best arbiter.
Idle is less efficient, but probably not prohibitively so. Changing a button label is a small thing computationally, and the unused messages require so little CPU they probably aren't noticeable, and perhaps not even easily measurable on sufficiently fast systems.
The idle solution will do what you're looking for, but is this app for yourself or to share with others?
The bigger challenge here seems less a technical concern in the messaging as much as a usability concern with having to remember a hidden option and also the means of revealing that option.
We spend so much time making our own software it's easy to forget how much time users spend with software that isn't ours. So being as gentle as possible with cognitive load goes a long way toward user satisfaction; users are busy, often distracted, and have to deal with a lot of systems all day that demand a lot of their attention.
Having both actions visible as separate buttons lets the user know there are two actions, without having to remember anything.
If available space is so critically limited it just isn't practical to display both action buttons at once, two options that come to mind are:
- Consider icons instead of labels for the buttons (if such images convey the action clearly).
- Consider putting both labels in a pulldown Action menu, where you could also add any other functionality you might think of later on.
But of course these notions are from someone who knows neither the UI nor the use case, so your good judgement with your hands-on knowledge is the best arbiter.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Livecode Opensource Backer
- Posts: 9364
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Change button label by pressing the command key
"sorry"
Don't be, ongoing, positive, discussion does not need apologies.
Don't be, ongoing, positive, discussion does not need apologies.
-
- VIP Livecode Opensource Backer
- Posts: 9656
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Change button label by pressing the command key
@fJord
Note that you first have to go to the"Short Cuts" pane in the "keyBoard" pane in "System Preferences" and check the "Use F1, F2, etc keys..."
This will give you a one-keyPress solution, as you wanted with the commandKey. This is because LC has a "functionKey" message.
I have always wondered if I really know how things work. The label of that system preferences button seems to tell me that it really ought to be unchecked, not checked. I should have posted this to the beginners section. Is there a LC property that overrides that system preference setting? I bet there is, since I assume I don't know how things work.
Craig
Try this on a new card:2° function keys: I don’t know how to use these but that’s drifting from my original post.
Code: Select all
on functionKey tkey
answer tkey
end functionKey
This will give you a one-keyPress solution, as you wanted with the commandKey. This is because LC has a "functionKey" message.
I have always wondered if I really know how things work. The label of that system preferences button seems to tell me that it really ought to be unchecked, not checked. I should have posted this to the beginners section. Is there a LC property that overrides that system preference setting? I bet there is, since I assume I don't know how things work.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 125
- Joined: Tue Apr 11, 2006 7:02 pm
- Location: Seattle, WA
- Contact:
Re: Change button label by pressing the command key
Hi François. If there is no other user input than to press the commandKey, my suggestion will not help.
If the user moves or clicks their mouse during the check, then moveMove will catch the action.
If you are not expecting the user to move the mouse or click anywhere while doing a command key is down check, my suggestion will not help.
Mark Talluto
--
Canela
design - develop - deploy: https://appli.io
Database and Cloud for LiveCode Developers: https://livecloud.io
Company: https://canelasoftware.com
--
Canela
design - develop - deploy: https://appli.io
Database and Cloud for LiveCode Developers: https://livecloud.io
Company: https://canelasoftware.com
Re: Change button label by pressing the command key
@Richard:
I agree 110% ! This app is just for myself; and even then, I may find that I forgot the double meaning of the button.The bigger challenge here seems less a technical concern in the messaging as much as a usability concern with having to remember a hidden option and also the means of revealing that option.
We spend so much time making our own software it's easy to forget how much time users spend with software that isn't ours. So being as gentle as possible with cognitive load goes a long way toward user satisfaction; users are busy, often distracted, and have to deal with a lot of systems all day that demand a lot of their attention.
Having both actions visible as separate buttons lets the user know there are two actions, without having to remember anything.
--
François
François
Re: Change button label by pressing the command key
@Dunbar:
Thanks for the info.
Interesting to know that… except for the fact that I couldn't find the "Use F1…" in System Prefs > Keyboard > Shortcuts. But no problem, for now.Try this on a new card:
CODE: SELECT ALL
on functionKey tkey
answer tkey
end functionKey
Note that you first have to go to the"Short Cuts" pane in the "keyBoard" pane in "System Preferences" and check the "Use F1, F2, etc keys..."
Thanks for the info.
--
François
François
-
- Livecode Opensource Backer
- Posts: 9364
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Change button label by pressing the command key
Nor could I: and just to be ridiculous, I checked in Mac OS 10.6.8 as well as Mac OS 12.5 beta 4.I couldn't find the "Use F1…" in System Prefs > Keyboard > Shortcuts.
It just so happens I have 2 Macs running at the moment with those operating systems . . .
. . . it is all to do with recovering the contents of documents written in ClarisWorks 5 . . . 'nuff said.
- -
Not particularly groovier than fishing for code in old HyperCard stacks.
Last edited by richmond62 on Tue Jul 05, 2022 7:36 pm, edited 1 time in total.
Re: Change button label by pressing the command key
Hi François,Fjord wrote: ↑Thu Jun 02, 2022 9:49 pmHi,
I'm wondering how / if I can change a button label just by holding, say, the command key. I have a button script along these lines:It would be much neater to have the button label change from 'do something' to 'do something to all' whenever the command key is pressed. But I can't find a way, other than using a 'on idle' handler (which is not recommended) or some kind of timer with 'send'.on mouseUp
if the eventCommandKey is up then
do something on the current card
else do the same thing on all cards
end mouseUp
Can one trap the pressing of the command key alone?
From your example, it appears to me that your objective is to change the action of a button triggered by a mouseUp message. If the user changes the label of a button based on a keyboard action, he/she must still initiate the action via the mouse.
My approach to modifying a button's mouseUp action uses the right mouse button to trigger an alternative to the main function of the button:
Code: Select all
on mouseUp whichButton
-- this is pseudo code, not LC syntax
if whichButton is not 3 then -- 3 = right button
do something on the current card
else do the same thing on all cards
end mouseUp
Cheers!
Rob Cozens dba Serendipity Software Company
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.