Working with sub stacks

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Working with sub stacks

Post by kdjanz » Sun Aug 22, 2021 9:55 pm

I'm working on a simple Fuel Economy app where the user needs to enter numbers. Two questions:

1. On mobile devices, the dictionary says that I can use

Code: Select all

 set the keyboardType of field "odd" to "numeric"
- but where do I put that line of script? In the openCard script? In mouseEnter?
Substack.jpg
When I am working in the IDE, I made a subStack that mimics the numeric keyboard. How do I go about calling it when I click in the field, and how do I move the entered number from the subStack back to the main stack to fill the field?

Thanks for the help!

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: Working with sub stacks

Post by andresdt » Sun Aug 22, 2021 10:07 pm

Hello, I do it as follows.
It doesn't mean it's correct, but it works for me.

in the stack code

Code: Select all


on preOpenStack
...
   if the platform is in "android iphone" then
       mobileSetKeyboardDisplay "pan"
    end if
...
end preOpenStack

and in the field code use:

Code: Select all


on openField
     if the environment is "mobile" then
         mobileSetKeyboardType "numeric"
     end if
     pass openField
end openField

on keyDown theKey
   if theKey is not a number then beep
   else pass keyDown
end keyDown

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Working with sub stacks

Post by jmburnod » Sun Aug 22, 2021 10:14 pm

Hi,
I'd use a group instead a stack to do what you describe.
That is the way i choose to display a custom keyboard.
I think you may use open/close field to show/hide your custom keyboard
Best regards
Jean-Marc
https://alternatic.ch

kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Re: Working with sub stacks

Post by kdjanz » Sun Aug 22, 2021 11:54 pm

Thanks for the ideas. Since the keypad is already grouped, I think I will try that first as the simplest

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Working with sub stacks

Post by jmburnod » Mon Aug 23, 2021 2:34 pm

Finnaly you can test these two ways and choose the best. Depends the evolution of your app
LC is great for that.
Jean-Marc
https://alternatic.ch

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”