×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    54

    GUI objects update issie

    Let's say I have two forms: form1 and form2.

    After pressing a NEXT_COMMAND in form1, I need to change the value of the gauge in form2 and then show form2. Thus:

    Code:
    public void commandAction(Command command, Displayable displayable) {
    ....
    else if (displayable == form1) {
        if (command == NEXT_COMMAND) {
            form2_gauge.setValue(value);
            display.setCurrent(form2);
        }
    ....
    }
    ....
    However, this doesn't work as I expected it to. It doesn't change a thing at first. On the other hand, if I go back from form2 to form1 and then again from form1 to form2 it would work.

    I can't figure it out myself. I'd be enormously grateful of any possible help.

    Thanks!
    Last edited by dumbledore1905; 2010-09-22 at 18:18.

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: GUI objects update issie

    First thing to note about setCurrent()... if you call it while handling an event (like paint() or commandAction()), then nothing will happen until the event-handler method returns.

    Second thing: if you call setCurrent() more than once during the same event, only the last one will take effect.

    One of these two situations is probably your problem.

    Graham.

  3. #3
    Registered User
    Join Date
    Sep 2010
    Posts
    54

    Re: GUI objects update issie

    Thank you, Graham! But I still don't understand why it should happen. The event sequence, as I see it, is:

    command action start -> gauge.setValue -> call setCurrent -> . . . -> command action end -> setCurrent does its job

    My point is, I don't see how one could have gauge.setValue and switching the displayable in reversed order? Isn't my piece of code simple enough?

  4. #4
    Registered User
    Join Date
    Sep 2010
    Posts
    54

    Re: GUI objects update issie

    One guy at stackoverflow advised to swap the setValue and setCurrent methods. And it worked. Do you have any idea why?! It's important not to have things happening at random in my code.

    In other words:

    Code:
    public void commandAction(Command command, Displayable displayable) {
    ....
    else if (displayable == form1) {
        if (command == NEXT_COMMAND) {
    
            display.setCurrent(form2);
            form2_gauge.setValue(value);
    
        }
    ....
    }
    ....
    Thanks!

  5. #5
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: GUI objects update issie

    Ah... so it does switch form, but the gauge has the wrong value? Sorry, I misunderstood.

    No, no idea, unless there is some bug in the implementation of Gauge on the device or emulator you're using. You might find that another device/emu works fine with your original code.

    Graham.

  6. #6
    Registered User
    Join Date
    Sep 2010
    Posts
    54

    Re: GUI objects update issie

    Two things I have to add.

    Firstly, the code is really simple and auto-generated by netbeans.

    Secondly, this kind of behaviour is observed when trying to set any kind of item on the form one is switching to. Pretty odd.

    Thanks as usual!

Similar Threads

  1. Thread Update GUI
    By tototmlg in forum Symbian C++
    Replies: 1
    Last Post: 2009-04-28, 15:47
  2. Replies: 0
    Last Post: 2009-04-23, 15:00
  3. Replies: 8
    Last Post: 2009-03-31, 09:18
  4. how to draw objects using gui
    By amitkamboj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2009-01-14, 12:58
  5. Replies: 1
    Last Post: 2007-04-16, 08:57

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •