Anybody have example of sliding text?

Does anybody have some sort of example how to scroll for instace a long text in highpowermode?

I mean a word like: I do not fit...       << (I do not fit here but scrolling fits)

is shortened with three dots ... and the rest of it would scroll smoothly in highpowermode like in Garmin navigation menu forth and back so that the word would look like:
...fit here but scrolling fits...

Perhaps you get the idea?-)

I probably have to start a timer with quite a small delay and somehow move the text... but any hints - appreciated!

  • That is pretty much exactly what you'd need to do. In some cases you can use WatchUi.animate() to animate stuff, but people often just do the work themselves and use a timer.

  • Here's an example of a device app with just scrolling text (no dots). It would need some work to be adapted your particular use case, but hopefully it helps somewhat.

    Unfortunately the forum won't accept the code I posted, so it's on this external site instead:

    https://pastebin.com/yyQaEZEi

    (EDIT:

    v2: update comment, update example for scrolling across ~half the screen width

    v3: when scrolling wraps, slide text in smoothly from the edge, instead of making entire string suddenly appear)

  • Excellent, thanks a lot. This gives me a excellent starting point Muscle tone1

  • No worries! I made a couple of edits in the last few minutes, so you might want to check out the latest link.

  • Give me your paypal account and I buy you a beer Ok hand tone1

  • updateTimer.start(method(:triggerUpdate), 50 /* ms */, false);
    A small flaw I noticed is the repeat should be true.
    Thanks for your share. You do save my life. Share a cool thing I made with your code snippet.
  • Nice! Looks great :)

    updateTimer.start(method(:triggerUpdate), 50 /* ms */, false);
    A small flaw I noticed is the repeat should be true.

    I don't think so, because updateTimer.start() is called every time onUpdate() runs, and the timer expiration causes onUpdate() to be called again. It's done that way on purpose. I could've used a repeating timer, but then I would only want to call updateTimer.start() once.

    (The assumption here is that WatchUi.requestUpdate() always causes onUpdate() to run.)

    I should really post stuff like this as github gists or something, so it's easier to update / collaborate.

  • How is it on an actual device?  It won't scroll unless it's a device with liveUpdates = true, and ones that do, it may impact the speed of going through the glances.  (what if there were 3 using 50ms timers next to each other?)

  • Oh, I see. I start the time in initialize function.  It is the difference.