Widget methods semantics

5 posts / 0 new
Last post
Vasily Zakharov
Jolaf's picture
Offline
Mobile Conjurer
Joined: 6 Apr 2010
Posts:
Widget methods semantics

I'm trying to create my own widget, and I wonder what methods beyond drawWidget() I have to reimplement.

In particular, I couldn't quite get the semantics of update(), requestRepaint() and setDirty().

When are they called by the MAUI engine and what could be the reasons to reimplement them?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Y'know, I was sure I'd written a tutorial on creating new Widgets, but it appears that I haven't! This one will be useful though.

http://www.mosync.com/documentation/tutorials/introduction-maui

drawWidget() is the only essential one, and that doesn't even have to have any implementation. You don't have to to use update, requestRepaint and setDirty unless you've a specific requirement.

requestRepaint causes the widget to be redrawn on the next update and asks the engine to check all the widgets, setDirty marks it is as requiring redrawing but doesn't instruct the engine to do the redraw.

Vasily Zakharov
Jolaf's picture
Offline
Mobile Conjurer
Joined: 6 Apr 2010
Posts:

rival, thanks! Surely, I've read that article. Smile But in only covers drawWidget().

Ok, I now understand requestRepaint() and setDirty(), but what is update() used for? When is it called by the engine? What would happen if I override it and/or call it myself?

I suspect I have a "specific requirement", but it's complex to explain. Smile

Niklas Nummelin
niklas's picture
Offline
Mobile Wizard
Joined: 18 Dec 2007
Posts:

Update is run on all widgets in the hierarchy before it is drawn. For example if you add a widget to a layout or a listbox, they don't have to rebuild their internal structures until update is run. This is made to save some computing time by not having to redo the same thing several times.

// Niklas

Vasily Zakharov
Jolaf's picture
Offline
Mobile Conjurer
Joined: 6 Apr 2010
Posts:

Niklas
Great! That's exactly what I need!

Thank you!