Page 1 of 1

[How To] Show fields based on options

Posted: Thu Jun 12, 2014 8:00 pm
by palanolho
Hi everyone,


On my application, I have a stack that will work as a options dialog.
On this stack I have several fields, but some of the fields should be different based on the value of a option button (one of the fixed fields).

EX:
--------------------
Field AA
Field BB
Option Button = 1
>> Field CC
>> Field DD
--------------------
Field AA
Field BB
Option Button = 2
>> Field EE
>> Field FF
--------------------

Anyone has any suggestion on what would be the best way to do this?

Many thanks in advance,
- Miguel

Re: [How To] Show fields based on options

Posted: Thu Jun 12, 2014 8:28 pm
by dunbarx
Hi.

On a new card drag over a new option menu. Put this into its script:

Code: Select all

on menuPick pItemName
   answer the menuHistory of me
end menuPick

on menuPick pItemName
   answer "Number" && menuHistory of me
end menuPick

on menuPick pItemName
   switch pItemName
      case "choice 1"
         answer "Number 1"
         break
      case "choice 2"
         answer "Number 2"
         break
   end switch
end menuPick

on menuPick pItemName
   switch pItemName
      case "choice 1"
      case "choice 2"
         answer pItemName
   end switch
end menuPick
Comment out one or the other. This gives you several ways (there are others) to think about how to make the users selection do what you want. Do you need help translating the results of the menu selection to your own task?

Craig Newman

Re: [How To] Show fields based on options

Posted: Thu Jun 12, 2014 9:13 pm
by palanolho
OK maybe I did not explain correctly.

I know how to check for changes on the option button and based on that, execute something.

My question was regarding the fields that should be visible / hidden.

The idea is that the fields will be displayed on the same place (so no empty areas when ones disappear and the others become visible)

Should I implement this with different cards? with groups and changing the group content?
You know what I mean?

thanks

Re: [How To] Show fields based on options

Posted: Thu Jun 12, 2014 10:14 pm
by dunbarx
Hi again.

So if you have two fields with the same rect and at the same loc, what is wrong with simply showing one and hiding the other on the same card? I wonder if there would be a noticeable glitch if you do that. But you can always lock and unlock the screen. Are there visual effects involved?

If the fields to be shown and hidden are always the same, you can group them to simplify the process. Otherwise you can "group" then by some property, to identify them as you cycle through whatever process you use to show/hide.

I still suspect that I am not understanding, since I bet you knew all of what I just said already as well.

Craig

Re: [How To] Show fields based on options

Posted: Fri Jun 13, 2014 8:35 am
by palanolho
Lets see if an image helps :)

Imagine a stake like this, where the field OPTION (in red) define which fields are visible below it:

Image

Is it clearer now ?

Re: [How To] Show fields based on options

Posted: Fri Jun 13, 2014 8:55 am
by Simon
Hi Miguel,
Yeah, that looks like hide/show group.
2014-06-13_0053.png
Simon

Re: [How To] Show fields based on options

Posted: Fri Jun 13, 2014 8:57 am
by palanolho
Okidoky

thanks :)