Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
popupMenu: m["xx"] has id=0
#1
I am building a popupmenu doing

m = new popupMenu();
m["x1"] = o => { ... }
etc.
sel = m.Show();

(ok, it's more complex than that - but you get the idea.)
It dawned on me that I should check if the user pressed <Esc> (and possibly undo a few things). According to the doc, sel will be =0 if Esc and id of selected item otherwise.

Well...test have shown me that m["x1"] does not have an id. How can I assign one? (I can't figure out from the doc...)
#2
To detect Cancel can be used m.Result.

Code:
Copy      Help
var m = new popupMenu();
m["x1"] = o => { print.it(o.Id); }; //no id
m.Add(5, "Explicitly set id");
m.Add("Auto-generated id");
m.Add("Explicitly set id", o => { print.it(o.Id); }).Id = 100;
int sel = m.Show();
print.it(sel, m.Result); //m.Result null if canceled


Forum Jump:


Users browsing this thread: 1 Guest(s)