[NTLK] Got a Newton programming question/issue
Matthias Melcher
m.melcher at robowerk.de
Thu Apr 17 07:51:07 PDT 2025
> On 13. Apr 2025, at 03:37, Alex Brofsky <alex.brofsky at gmail.com> wrote:
>
> So, I'm trying to add some preference options to my Dogcow app. I want to
> include an option for a user to select between three different Dogcow
> designs.
>
> I'm using a clPictureView for displaying the Dogcow image.
>
> I already implemented the "DoInfoPrefs" item for the "protoInfoButton"
Yes, that looks good so far, and the method is called as expected. You can use it to open a `newtPrefsView`. If your app is based on `NewtAppliction`, I believe you can create that view in the `NewtApplication.prefsView` slot. I also found "Your application may override GetAppState, SaveAppState, and
GetDefaultState to add your own application preferences."
That is the GUI side of things. I have not tried that out though.
To read and change preference, you can use `GetAppPrefs(appSymbol, defaultFrame)` to get the soup entry that contains your preferences. You can then read the entry and also change it as needed. Call `EntryChange()` to write the data back to the soup.
Here is an example to query preferences from the PreeferMadness sample code:
func viewSetupFormScript() begin
prefsEntry := GetAppPrefs(kAppSymbol, kPrefsFrame) ;
if prefsEntry.startWithSound then
PlaySound(kStartSound);
...
prefsEntry.startWithSound := false;
EntryChange(prefsEntry);
end
> I tried looking through the various sample code that's included in the
> Newton Dev setup: http://www.unna.org/view.php?/development/NewtonDev
>
> I found a few things that may work as a base but they won't run in Einstein
> for some reason. Mainly "Photo Album-1".
I am surprised. How do they fail on Einstein?
> Where do I begin to actually add options in a pref menu to change the
> displayed icon value for clPictureView?
I assume you need to open a prefs panel that can then in turn have check boxes and pulldown selections as needed.
> I've uploaded my v3.0 WIP code. If someone could take a look at it, that
> would be incredible.
> https://mega.nz/file/jtAUCAba#I8NpS0VGBVfvOJiJp5UZJxNkaRW2ixMkKtc2YP0HcV8
Thanks for all the information. I have not written much in NewtonScript, so much of what I write is "how I understood this". Also I have not much spare time ATM, so sorry for the late reply.
- Matthias
More information about the NewtonTalk
mailing list