Question

I'm developing a Newton OS app in NewtonScript and the protoApp proto fits the application type better than the newtApplication proto (i.e. NewtApp). protoApp provides the title & status bar with close box, but how do I insert custom buttons in the status bar (since it only shows the clock)?

Was it helpful?

Solution

I found this thread on NewtonTalk, where Paul Guyot says:

You don't need to use protoApp. You can use protoFloater instead. You can then add a nicer NewtonOS 2.x-like status bar to replace the ugly clock/battery picker of protoApp and put the close box on this bar. The trick is to steal the bar from the NewtApp framework, i.e. to use newtStatusBarNoClose. I did this for several projects, it's probably documented as is in the doc (the fact that you can use newtStatusBar[NoClose] instead of protoStatusBar) and you can take advantage of the buttons handling code (to align them automatically on the left and on the right).

It turns out the suggestion of using newtStatusBar instead of protoStatus is documented in the Newton Programmer's Guide (2.0) on page 7-19:

Note
The new status bar protos newtStatusBarNoClose and newtStatusBar, are the preferred way to add a status bar to your applications. These protos, which are described in “NewtApp Applications” (page 4-1), simplify adding buttons and automate hiding the close box when your application is moved into the background.

And, Paul's suggestion of using protoFloater instead of protoApp was dead-on, although, I actually ended up using protoDragger. I had to manually add the protoTitle & protoStatusBar:

mainView := {
    _proto: protoDragger,
    viewflags: vApplication + vVisible + vClickable,
    appSymbol: kAppSymbol,
    viewJustify: vjParentFullH + vjParentFullV,
    viewBounds: {left: 16, top: 16, right: -16, bottom: -16},
    stepChildren: [
        {
            _proto: protoTitle,
            title: kAppTitle
        },
        {
            _proto: newtStatusBar,
            menuLeftButtons: [],
            menuRightButtons: []
        },
    ],
};

OTHER TIPS

The Newton proto and view framework is pretty flexible, so while it is nice to have something like NewtApp do a lot of magic behind the scenes, I found it often works as well to just directly code the layout as needed. In the example below, I just create a button as a child view of the app, and move it to the right spot. I don't thing we have to expect a lot of changes to the protos anymore, so the pixel values can be fixed as such :)

mainView := {
    _proto: protoApp,
    title: "App Title",
    appSymbol: 'appSymbol,

    stepChildren: [
        {
            _proto: protoTextButton,
            text: "Custom",
            viewJustify: vjParentRightH + vjParentBottomV + vjCenterH,
            viewBounds: {left: -70, top: -16, right: -26, bottom: -3}
        },
    ],

    viewJustify: vjParentFullH + vjParentFullV,
    viewBounds: {left: 16, top: 16, right: -16, bottom: -16},
};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top