Topic
  • 3 replies
  • Latest Post - ‏2014-03-03T12:52:32Z by pommCannelle
Scaramouch
Scaramouch
3 Posts

Pinned topic DXL: rename buttons

‏2014-02-27T09:05:29Z |

Hello Falk's,

does anyone know, how renaming buttons work?

 

STB

  • llandale
    llandale
    2972 Posts
    ACCEPTED ANSWER

    Re: DXL: rename buttons

    ‏2014-02-28T18:00:30Z  

    I don't think you can rename a "button" after the realize.  set(dbeButton, "SomeNewLabel") fails.

    But if you know ahead of time the finite set of available button labels, you can create that many Buttons, one on top of the other, and hide or show them as needed.  To demonstrate, run the following and push the button a few times.

    DB db
    DBE dbe1, dbe2, dbe3

    void  buttonChange(DBE input_dbe)
    {
       hide dbe1
       hide dbe2
       hide dbe3
       if    (input_dbe == dbe1) then show dbe2
       elseif(input_dbe == dbe2) then show dbe3
       elseif(input_dbe == dbe3) then show dbe1
       else {} // all cases covered
    } // end buttonChange()

    db = create("Toggle Buttons")
    dbe1  = button(db, "Button 1111", buttonChange)
    dbe2 = button(db, "Button 2222", buttonChange)
    dbe3 = button(db, "Button 3333", buttonChange)

     dbe2 ->"top"  ->"aligned" ->dbe1
     dbe2 ->"left" ->"aligned" ->dbe1
     dbe3 ->"top"  ->"aligned" ->dbe1
     dbe3 ->"left" ->"aligned" ->dbe1
    show(db)

    Notice all the buttons are associated with the same callback buttonChange().  Haven't had luck with the "stacked(DBE)" command, maybe someone can show how that is used.

    -Louie

  • llandale
    llandale
    2972 Posts

    Re: DXL: rename buttons

    ‏2014-02-28T18:00:30Z  

    I don't think you can rename a "button" after the realize.  set(dbeButton, "SomeNewLabel") fails.

    But if you know ahead of time the finite set of available button labels, you can create that many Buttons, one on top of the other, and hide or show them as needed.  To demonstrate, run the following and push the button a few times.

    DB db
    DBE dbe1, dbe2, dbe3

    void  buttonChange(DBE input_dbe)
    {
       hide dbe1
       hide dbe2
       hide dbe3
       if    (input_dbe == dbe1) then show dbe2
       elseif(input_dbe == dbe2) then show dbe3
       elseif(input_dbe == dbe3) then show dbe1
       else {} // all cases covered
    } // end buttonChange()

    db = create("Toggle Buttons")
    dbe1  = button(db, "Button 1111", buttonChange)
    dbe2 = button(db, "Button 2222", buttonChange)
    dbe3 = button(db, "Button 3333", buttonChange)

     dbe2 ->"top"  ->"aligned" ->dbe1
     dbe2 ->"left" ->"aligned" ->dbe1
     dbe3 ->"top"  ->"aligned" ->dbe1
     dbe3 ->"left" ->"aligned" ->dbe1
    show(db)

    Notice all the buttons are associated with the same callback buttonChange().  Haven't had luck with the "stacked(DBE)" command, maybe someone can show how that is used.

    -Louie

  • Scaramouch
    Scaramouch
    3 Posts

    Re: DXL: rename buttons

    ‏2014-03-03T08:53:23Z  
    • llandale
    • ‏2014-02-28T18:00:30Z

    I don't think you can rename a "button" after the realize.  set(dbeButton, "SomeNewLabel") fails.

    But if you know ahead of time the finite set of available button labels, you can create that many Buttons, one on top of the other, and hide or show them as needed.  To demonstrate, run the following and push the button a few times.

    DB db
    DBE dbe1, dbe2, dbe3

    void  buttonChange(DBE input_dbe)
    {
       hide dbe1
       hide dbe2
       hide dbe3
       if    (input_dbe == dbe1) then show dbe2
       elseif(input_dbe == dbe2) then show dbe3
       elseif(input_dbe == dbe3) then show dbe1
       else {} // all cases covered
    } // end buttonChange()

    db = create("Toggle Buttons")
    dbe1  = button(db, "Button 1111", buttonChange)
    dbe2 = button(db, "Button 2222", buttonChange)
    dbe3 = button(db, "Button 3333", buttonChange)

     dbe2 ->"top"  ->"aligned" ->dbe1
     dbe2 ->"left" ->"aligned" ->dbe1
     dbe3 ->"top"  ->"aligned" ->dbe1
     dbe3 ->"left" ->"aligned" ->dbe1
    show(db)

    Notice all the buttons are associated with the same callback buttonChange().  Haven't had luck with the "stacked(DBE)" command, maybe someone can show how that is used.

    -Louie

    Thank you very much.

    STB

  • pommCannelle
    pommCannelle
    52 Posts

    Re: DXL: rename buttons

    ‏2014-03-03T12:52:08Z  
    • llandale
    • ‏2014-02-28T18:00:30Z

    I don't think you can rename a "button" after the realize.  set(dbeButton, "SomeNewLabel") fails.

    But if you know ahead of time the finite set of available button labels, you can create that many Buttons, one on top of the other, and hide or show them as needed.  To demonstrate, run the following and push the button a few times.

    DB db
    DBE dbe1, dbe2, dbe3

    void  buttonChange(DBE input_dbe)
    {
       hide dbe1
       hide dbe2
       hide dbe3
       if    (input_dbe == dbe1) then show dbe2
       elseif(input_dbe == dbe2) then show dbe3
       elseif(input_dbe == dbe3) then show dbe1
       else {} // all cases covered
    } // end buttonChange()

    db = create("Toggle Buttons")
    dbe1  = button(db, "Button 1111", buttonChange)
    dbe2 = button(db, "Button 2222", buttonChange)
    dbe3 = button(db, "Button 3333", buttonChange)

     dbe2 ->"top"  ->"aligned" ->dbe1
     dbe2 ->"left" ->"aligned" ->dbe1
     dbe3 ->"top"  ->"aligned" ->dbe1
     dbe3 ->"left" ->"aligned" ->dbe1
    show(db)

    Notice all the buttons are associated with the same callback buttonChange().  Haven't had luck with the "stacked(DBE)" command, maybe someone can show how that is used.

    -Louie

    Hi Louie !

    You can try this syntax

        dbe1  = button(db, "Button 1111", buttonChange)
        stacked(dbe1)
        dbe2 = button(db, "Button 2222", buttonChange)
        stacked(dbe2)
        dbe3 = button(db, "Button 3333", buttonChange)
        stacked(dbe3)

    and remove the constrained placement ... but i can't help you if you need to "reset" the stacked feature in order to be abble to stack an other set of DBE ... maybe someone else ? ;)

    Updated on 2014-03-03T14:09:23Z at 2014-03-03T14:09:23Z by pommCannelle