Whats wrong with this layout

Former Member
Former Member
I'm trying to get a simple layout to run to try to determine how to use button class. I started with the auto generated Watch App for an FR630 using ver 1.2 then exit the layout.xml file to look like the following

<layout id="MainLayout">
<label x="center" y="5" text="@Strings.prompt" color="Gfx.COLOR_WHITE" justification="Gfx.TEXT_JUSTIFY_CENTER" />
<bitmap id="id_monkey" x="center" y="30" filename="../drawables/monkey.png" />
<button x="center" y="center" width="150" height="40" background="Gfx.COLOR_BLACK" behavior="myButton">
<state id="stateDefault" color="Gfx.COLOR_GREEN" />
<state id="stateHighlighted" color="Gfx.COLOR_RED" />
<state id="stateSelected" color="Gfx.COLOR_BLUE" />
<state id="stateDisabled" color="Gfx.COLOR_PURPLE" />
</button>
</layout>


In the delegate.mc file, I add the the following function in

function myButton() {
System.println("Hello");
}


so it now looks like this

using Toybox.WatchUi as Ui;

class Delegate extends Ui.BehaviorDelegate {

function initialize() {
BehaviorDelegate.initialize();
}

function onMenu() {
Ui.pushView(new Rez.Menus.MainMenu(), new MenuDelegate(), Ui.SLIDE_UP);
return true;
}

function myButton() {
System.println("Hello");
}

}


mainly so I could include the "behavior" attribute and point it to a function. It's an optional attribute according to the docs, but it makes no difference if I include it or not.

When run in the simulator, it does as expected and produces a button that can be clicked, changes color when clicked, and with the delegate, displays the Hello message in the console.

When this app is placed onto an actual FR630, it dies on startup and never gets to display anything.

I have been trying to figure this our for hours and getting nowhere.

Can anyone se anything I may have done thats preventing this from working ?
  • There is nothing wrong with your code. I'm fairly certain that the problem is that you are using functionality (button in the layout creates a Ui.Buttton) that is available in ConnectIQ 2.1.0, but the device (fr630) does not have support for it.

    Out of curiosity, what does the CIQ_LOG.txt say about it?

    Travis
  • Former Member
    Former Member over 8 years ago
    Looks like you're probably correct. CIQ_LOG.txt has the following

    ERROR: Symbol Not Found Error
    DETAILS:
    STORE_ID: 00000000000000000000000000000000
    CALLSTACK:
    Rez (MainLayout:41)
    C:\workspace\test\source\TestView.mc (onLayout:11)


    Pitty it doesnt say which symbol is missing.

    I'd also like to see the simulator better report API functions that aren't available when a model is selected (I had the fr630 as the only selected model).

    It would appear the simulator has all features from all units enabled all the time and it's up to the programmer to decide whats available.

    I guess I'll have to create bitmaps with the text in them :)

    Thanks for the help.
  • I guess I'll have to create bitmaps with the text in them

    If all you're doing is creating bitmaps with text overlays you don't need to use button at all. Just put a Ui.Bitmap in the layout then put a Ui.Text on top of it. Should be no problem and should work with all current devices (back to the 1.0.0 SDK).

    The nice thing about the built-in Button is that it invokes callbacks on the current delegate automatically. If you want, I'm pretty sure I could take some code that I have from before button support was added to the SDK, and make it behave like the built-in button code. It would require some tiny changes to your code, but I'm pretty sure it could be made to work. Let me know if you want it and I'll dig it out.

    Travis
  • Former Member
    Former Member over 8 years ago
    Thanks for the offer Travis but I'll play around with some other ideas. Shouldn't be too hard to get it to work like a button.
  • Once you have it on the screen, in the your Delegate, use onTap() and check the x/y to see if it's where the button is (if you plan on supporting the va and va-hr, they have 9 "tap regions" so you may want to align your screen button to one of those)