Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 1.96 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Toolbar radio buttons have a (display at least, didn't look at the code)
  2. // bug: click on second button, then click again on it - the second button
  3. // will get deselected and the first button will get selected. Of course,
  4. // you might argue that it inherits from form.ToggleButton and thus it's
  5. // toggled "off" when you click the second time. But in this case, the
  6. // object should be called ToggleButton and not RadioButton. Another issue
  7. // with this behaviour is that when I click the second time, the execute
  8. // event is executed on the second button (the one that gets deactivated)
  9. // and not on the first, which gets activated.
  10. var button1 = new qx.ui.toolbar.RadioButton("First Button");
  11. var button2 = new qx.ui.toolbar.RadioButton("Second Button");
  12. var button3 = new qx.ui.toolbar.RadioButton("Third Button");
  13. /*
  14. // The problem I found here is that if I click a second time on the already
  15. // selected button, I'll still get an execute event and I see no reason to
  16. // that.
  17. var button1 = new qx.ui.form.RadioButton("First Button");
  18. var button2 = new qx.ui.form.RadioButton("Second Button");
  19. var button3 = new qx.ui.form.RadioButton("Third Button");
  20. */
  21.  
  22. new qx.ui.form.RadioGroup(button1, button2, button3);
  23.  
  24. var doc = this.getRoot();
  25.  
  26. doc.add(button1, {left : 100, top  : 50});
  27. doc.add(button2, {left : 100, top  : 100});
  28. doc.add(button3, {left : 100, top  : 150});
  29.  
  30. // Alas, there is one thing which I find missing: the ability to cancel
  31. // the selection of a button. Let's say I've clicked the second button, some
  32. // changes occured in the pages and if I were to click on the first button,
  33. // I'd lose my changes. So, naturally, I'd like to display a confirmation
  34. // dialog and allow the user to choose whether he wants to allow the change.
  35. button1.addListener("execute", function(e) {
  36.   alert("first");
  37. });
  38.  
  39. button2.addListener("execute", function(e) {
  40.   alert("second");
  41. });
  42.  
  43. button3.addListener("execute", function(e) {
  44.   alert("third");
  45. });