Active field when opening card?

Want to move your code and projects to LiveCode but don't know where to start?

Moderators: FourthWorld, heatherlaine, Klaus, robinmiller

Post Reply
dwolff
Posts: 5
Joined: Mon Nov 13, 2006 4:53 am

Active field when opening card?

Post by dwolff » Mon Nov 13, 2006 11:37 pm

Hi all,

I'm converting many stacks from HyperCard to Revolution. Several of these have many fields, like address book stacks. One problem I have not yet gotten past: When a card opens, one of the fields is selected (active). So, among other problems, if I accidentally type something, the field text is destroyed.

How can I turn off this auto-select behavior? Where is it set?

Thanks --

David

marielle
Livecode Opensource Backer
Livecode Opensource Backer

Re: Active field when opening card?

Post by marielle » Tue Nov 14, 2006 12:35 am

dwolff wrote:So, among other problems, if I accidentally type something, the field text is destroyed.
Check out these in the dictionary

focus
Use the focus command to make a control active--that is, to make it receive any keystrokes the user types.

(obviously, you will choose to set the focus on a control *other* than the field... for instance an "ok" button or some non editable nterface element)

traversalOn
Setting a field's traversalOn to true enables the user to tab into or click in the field for editing (if the field's lockText property is false). If a field's traversalOn and lockText properties are both set to true, the user can select text, but not change it, and can scroll within the field using the keyboard. If the traversalOn is true and the lockText is false, the field can be edited. If the lockText is true and the traversalOn is false, the user can neither select nor edit the field's text.

dwolff
Posts: 5
Joined: Mon Nov 13, 2006 4:53 am

Post by dwolff » Tue Nov 14, 2006 6:26 am

Thanks, I've read each of those umpty-twelve times. :cry:

Does Revolution automatically set the focus to one of the group fields? Can I turn off that behavior other than by setting the focus elsewhere, on every OpenCard?

Thanks --

David
[/quote]

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Nov 14, 2006 10:30 am

Assuming that Revolution always focuses on field 2 while you want field 1 to be focuses on openCard, the following script does the job:


on preOpenCard
repeat with x = 1 to number of fields
set the traversalOn of fld x to false
end repeat
end preOpenCard

on openCard
repeat with x = 1 to number of fields
set the traversalOn of fld x to true
end repeat
focus on fld 2
end openCard

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Post by Garrett » Wed Nov 15, 2006 12:19 pm

Yes, you can use the "on opencard" in the card's script and focus on any
object you wont, of course avoiding the objects you don't want focused
on.

In the documentation, scroll down to "focus".
Summary:
Places the insertion point in a field or makes a control active.

Examples:
focus on field "Label"
focus on the mouseControl
focus on graphic "Move Me"
I imagine though that you'll need another object that has the ability to be
focused on in order to take the focus away from any object you don't
want the focus on.

-Garrett

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Nov 15, 2006 12:34 pm

Hi Garrett,

First of all, you don't need another object. However, even if you had another object to take the focus away, as you call it, opening the card would automatically re-focus the first field. That is why I turn off the traversalOn of all fields on preOpenCard and turn then on again on openCard, in my example. There may be a simpler way, but at least I know that this method never never fails.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Post by Garrett » Thu Nov 16, 2006 9:52 pm

Wow, that's a bummer. I didn't know that happens. :-(

-Garrett

dwolff
Posts: 5
Joined: Mon Nov 13, 2006 4:53 am

Re: Active field when opening card?

Post by dwolff » Wed Nov 22, 2006 3:58 am

marielle wrote:
dwolff wrote:So, among other problems, if I accidentally type something, the field text is destroyed.
Check out these in the dictionary

<snippage>

traversalOn
Setting a field's traversalOn to true enables the user to tab into or click in the field for editing (if the field's lockText property is false). If a field's traversalOn and lockText properties are both set to true, the user can select text, but not change it, and can scroll within the field using the keyboard. If the traversalOn is true and the lockText is false, the field can be edited. If the lockText is true and the traversalOn is false, the user can neither select nor edit the field's text.
So. Revolution always focuses on a traversable field on every OpenCard, yes? (This is not documented that I can find. It's also different from HyperCard behavior, so it's snagged me.)

Is there anywhere a list of what messages are sent during various events such as opening a card?

Now I'm looking for a simple way to lock things. Just checked the "cantmodify of this stack" and apparently that does not prevent editing fields!

Thanks --

David

dwolff
Posts: 5
Joined: Mon Nov 13, 2006 4:53 am

Post by dwolff » Sat Dec 16, 2006 3:33 am

Garrett wrote:Yes, you can use the "on opencard" in the card's script and focus on any
object you wont, of course avoiding the objects you don't want focused
on.

In the documentation, scroll down to "focus".
Summary:
Places the insertion point in a field or makes a control active.

Examples:
focus on field "Label"
focus on the mouseControl
focus on graphic "Move Me"
I imagine though that you'll need another object that has the ability to be
focused on in order to take the focus away from any object you don't
want the focus on.

-Garrett
I decided to take this course. (BTW, I couldn't find any documentation that matches your quote... where is that?)

The stack script now has this handler:

Code: Select all

On OpenCard
  Focus on bg field "EatRevFocusKludge"
  Pass OpenCard
End OpenCard
and there is an appropriate bg field.

The idea of un-setting and re-setting a property for every field on the card (possibly 10-20!) on every card open seemed... non-optimal.

It doesn't seem to want to focus on a button, as was suggested above, only a (traversable and enabled) field. Which however can be hidden behind another field. This has the disadvantage of eating left-arrow and right-arrow keys but I could add a script to the field to deal with this.

Again, is there a list of all messages sent by various actions?

Thanks --

David

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Dec 16, 2006 3:53 am

Again, is there a list of all messages sent by various actions?
No. There are the functions commandnames and functionnames, but there is no messagenames. So, there is no list of actions and related messages and there isn't even a list of messages. However, you can enter "message" as a query in the docs and you will get a list of all messages.

I don't think it is doable to compile an exhaustive list of all possible user actions and all invoked messages, such as: open a card, closeCard, openCard, preOpencard, possibly preOpenStack and openStack, etc etc etc.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

dwolff
Posts: 5
Joined: Mon Nov 13, 2006 4:53 am

Post by dwolff » Fri Dec 22, 2006 4:58 am

Mark wrote:
Again, is there a list of all messages sent by various actions?
<snippage>
I don't think it is doable to compile an exhaustive list of all possible user actions and all invoked messages, such as: open a card, closeCard, openCard, preOpencard, possibly preOpenStack and openStack, etc etc etc.
I must be really unclear.

Is there a list of the messages that Revolution automatically sends on various events, for example when going to a different card?

For example, in HyperCard, somewhere I have a list of what HyperCard sends when I delete a card (closeCard, deleteCard, then openCard; possibly with some xxxBackground messages if it was the last card in the background).

A book, maybe?

Thanks --

David

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Dec 22, 2006 7:11 am

Hi David,

I think you cut out the wrong part of the quote. As I wrote in me previous message:

...you can enter "message" as a query in the docs and you will get a list of all messages.

As far as I know, this is the only practicle way to get a list of messages.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9852
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Post by FourthWorld » Fri Dec 22, 2006 4:09 pm

Mark wrote:
Again, is there a list of all messages sent by various actions?
I don't think it is doable to compile an exhaustive list of all possible user actions and all invoked messages, such as: open a card, closeCard, openCard, preOpencard, possibly preOpenStack and openStack, etc etc etc.
And of it were it'd be too tedious to read. :)

It may be more helpful to examine messages interactively with the Message Watcher.

Post Reply

Return to “Converting to LiveCode”