Re: [NTLK] NewtonScript question

From: Paul Guyot (pguyot_at_kallisys.net)
Date: Wed Oct 27 2004 - 23:01:39 PDT


Aux environs du 26/10/04 à 21:58 -0700, sous le titre "[NTLK]
NewtonScript question", Blake Patterson prit sa plus belle plume pour
écrire les mots suivants:
>I am writing a NewtonScript app for OS 2.1. I have
>two protoPopupBottons in a window. I currently am
>populating the first popup with an array constant I
>set in a text file in the project. I want the options
>in the second popup to be dependent upon what the
>first popup is set to. Seems I'd do well to reference
>the itemSelected from the first popup to load the
>second with an array of appropriate choices.
>
>It seems, here, I'd need an array of arrays. Is this
>possible in newtonScript? And to reference the first
>popup, called popUp1, from within the second is it
>just reading popUp1.popup[itemSelected] ?

Of course you can have arrays of arrays in NewtonScript.

You can either build the list when a value in the first popup is
chosen (when PickActionScript is called) or when the second button is
tapped (before the popup occurs, when ButtonScript is called). In
both cases, change the popup slot of the second popup and you'll get
the effect you want.

Then, you can present data like this:
DefConst('kFirstPopupArray, ["foo", "bar", "foobar"]);
DefConst('kSecondPopupArray, [["foo-foo", "foo-bar"], ["bar-foo",
"bar-bar"], ["foobar-foo", "foobar-bar"]]);

and set popup of the second popup to
kSecondPopupArray[indexSelectedFirstPopup].

Alternatively, you can put frames in popup list with the string in
the item slot. Hence you could do:
DefConst('kPopupArray, [{
        item: "foo",
        subpopup: ["foo-foo", "foo-bar"]
        }, {
        item: "bar",
        subpopup: ["bar-foo", "bar-bar"]
        }, {
        item: "foobar"
        subpopup: ["foobar-foo", "foobar-bar"]
        }]);

and set popup of the second popup with:

secondPopup.popup := kPopupArray[indexSelected].subpopup;

Paul

-- 
Ministre plénipotentiaire en disponibilité.
Baignoire à vendre.
http://www.kallisys.com/
http://newton.kallisys.net:8080/
-- 
This is the NewtonTalk list - http://www.newtontalk.net/ for all inquiries
Official Newton FAQ: http://www.chuma.org/newton/faq/
WikiWikiNewt for all kinds of articles: http://tools.unna.org/wikiwikinewt/


This archive was generated by hypermail 2.1.5 : Wed Oct 27 2004 - 23:30:02 PDT