Navigating from once card to another problem

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

glenn9
Posts: 88
Joined: Wed Jan 15, 2020 10:45 pm
Location: Europe

Navigating from once card to another problem

Post by glenn9 » Thu Dec 03, 2020 1:21 pm

Hi everyone,

whilst typing in a field of card A my text will, depending on what is typed, trigger showing a card B.
I've got the code working for this along the lines of:

Code: Select all

on rawkeyup
... triggering condition...
go to card B
so far so good...
but when card B shows I still want to continue typing in card A, so I'd almost like a function in card B along the lines of...

Code: Select all

on 'somefunction'
go to field 1 of card A (and stay there!)
I've tried the above but the problem I've got is that each time I type in card A, I trigger a rawkeyup and therefore repeatedly go to card B - I just want to have gone to card B once - its a much smaller card than card A so I can refer to the information on card B whilst I'm typing in card A.

Not sure how to achieve this by script... grateful for any tips!

Kind regards,

Glenn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5242
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Navigating from once card to another problem

Post by richmond62 » Thu Dec 03, 2020 2:05 pm

its a much smaller card than card A
I'm lost here . . .

1. ALL cards in a stack are the same size.

2. How can you refer to one card while typing in the field of another card?

3. Why do I feel that what you are describing (if I understand it correctly) might not be better
with a stack "A" and a substack "B"?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7289
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Navigating from once card to another problem

Post by dunbarx » Thu Dec 03, 2020 2:44 pm

This can be done. I think Richmond's point was that you can only view one card at a time within a single stack.

So try this. Make a new stack with two cards. Put a field in card 1, and anything identifying on card 2. In the stack script:

Code: Select all

on keyDown tKey
   put tKey after fld 1 of cd 1
   if tKey = "x" then go cd 2
   if tKey = "y" then go cd 1
end keyDown
Start typing while viewing card 1. It does not matter if the field has focus or not. When you type an "X", you will find yourself on card 2. If you keep typing, you will continue to append to the field on card 1. If you type a "Y", you will go back to cd 1. You can seesaw back and forth all day if you want to.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5242
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Navigating from once card to another problem

Post by richmond62 » Thu Dec 03, 2020 2:55 pm

Richmond's point was twofold:

1. You can only see one card in a stack at one time.

2. You cannot have different sized cards in one stack.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7289
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Navigating from once card to another problem

Post by dunbarx » Thu Dec 03, 2020 3:22 pm

Richmond.

I did not really see the "much smaller" portion of the OP's post. You are correct in that either another stack (or resize a single stack based on which card is in front) is required.

So, Glenn, how important are the issues here? We already see that you can do the typing thing without a problem. How do you want to handle the card size thing? Richmond implied that the way forward was to be able to have one or both card windows open as you wish, at whatever size you wish, but with two separate stacks. That works fine, and I see no downside. But you could resize a single stack if you want to.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7289
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Navigating from once card to another problem

Post by dunbarx » Thu Dec 03, 2020 3:50 pm

Glenn.

Know that if you do choose to use two separate stacks, a slight modification to the stack script in stack 1 is required:

Code: Select all

on keyDown tKey
   put tKey after fld 1 of cd 1 of stack "untitled 1"
   if tKey = "x" then go cd 1 of stack "untitled 2"
   if tKey = "y" then go cd 1 of stack "untitled 1"
end keyDown
and the script of stack 1 has to be made into a back script:

Code: Select all

insert script of stack "untitled 1" into back
Not a big deal.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7289
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Navigating from once card to another problem

Post by dunbarx » Thu Dec 03, 2020 4:04 pm

It occurs to me that placing a keydown handler as a backScript is fraught with peril, unless you limit such a beast to the pertinent stacks;

Code: Select all

on keyDown tKey
   if the short name of this stack is  not"untitled 1" and the short name of this stack is  not "untitled 2" then pass keydown
   else
      put tKey after fld 1 of cd 1 of stack "untitled 1"
      if tKey = "x" then go cd 1 of stack "untitled 2"
      if tKey = "y" then go cd 1 of stack "untitled 1"
   end if
end keyDown
This is why testing is considered by some to be an important component of stack design.

Craig

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

Re: Navigating from once card to another problem

Post by FourthWorld » Thu Dec 03, 2020 5:23 pm

If you:

- place fld 1 of card A in a group
- set that field's sharedText to true
- set the group's sharedBehavior to true
- place the group on all cards

...then you can type into it from any card without the need to fiddle with multiple stacks, window focus, etc.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7289
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Navigating from once card to another problem

Post by dunbarx » Thu Dec 03, 2020 5:49 pm

Richard exploits a terrific feature of grouped sharedText fields; you are essentially typing into all such fields on all cards at once.

But does the OP want to see that " original" field when he moves to the "much smaller" card window? We do not know what that card looks like, that issue not yet dealt with. As for placing them on "all" cards, I am sure you meant only on cards where typing will continue, but I got the impression that when on the other smaller card, that field was neither needed nor wanted.

But if two stacks are required to manage different card sizes and/or styles, the backScript method, however kludgey, may be preferable.

Anyway, Glenn?

Craig

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

Re: Navigating from once card to another problem

Post by FourthWorld » Thu Dec 03, 2020 6:07 pm

dunbarx wrote:
Thu Dec 03, 2020 5:49 pm
Richard exploits a terrific feature of grouped sharedText fields; you are essentially typing into all such fields on all cards at once.

But does the OP want to see that " original" field when he moves to the "much smaller" card window?
Yes, this is based on a guess about the design goals. Given the frustration of typing something that can't be seen, I'm assuming the OP doesn't actually want to do that. Multi-window options seem based on the same assumption.

Many threads would benefit from a screen shot or deeper explanation of what's desired. This is one of them.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

SparkOut
Posts: 2350
Joined: Sun Sep 23, 2007 4:58 pm

Re: Navigating from once card to another problem

Post by SparkOut » Thu Dec 03, 2020 6:14 pm

Sounds like an info sheet just as a reference pane while working on the original card. Maybe a palette stack, or perhaps a bit like stam's popover widget viewtopic.php?f=7&t=34834&start=30#p197818

glenn9
Posts: 88
Joined: Wed Jan 15, 2020 10:45 pm
Location: Europe

Re: Navigating from once card to another problem

Post by glenn9 » Thu Dec 03, 2020 9:06 pm

Apologies, I'll try and insert an image of what I'm trying to achieve, just trying to figure out how to do this inset an image into the thread...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7289
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Navigating from once card to another problem

Post by dunbarx » Thu Dec 03, 2020 11:32 pm

Hi.

Attach your (zipped) image file using the "attachments" tab below the text field. This opens a button named "Add Files". You can opt to place it in-line once you have it.

Craig

SparkOut
Posts: 2350
Joined: Sun Sep 23, 2007 4:58 pm

Re: Navigating from once card to another problem

Post by SparkOut » Thu Dec 03, 2020 11:56 pm

Images don't need to be zipped (just not overly large)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7289
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Navigating from once card to another problem

Post by dunbarx » Fri Dec 04, 2020 4:46 am

Sparkout.

True? I thought all files had to be.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”