a = 1;
Button["Print", a++]
Button["Print", Dynamic[a++]]
Button["Print", Dynamic[a++];]
Button["Print", {Dynamic[a++]}]
Dynamic @ a
The second Button is not supposed to change the value of a but it does.
Have I missed something or is it a bug?
Why it is not supposed to?
Button[label,action][...] evaluates action whenever it is clicked.
Evaluation is supposed to leave Dynamic intakt and if it is part of returned result MakeBoxes will create DynamicBox which is supposed to be handled by FrontEnd which should send contents to evaluation when needed.
Yet the Button isn't creating any visible result when clicked.
While Button["Print", Dynamic[a++]] isn't useful in general, the leak is the leak.
A support case with the identification [CASE:3609709] was created
[...] I have filed an incident report with the information you provided.
[...] I have also filed a second incident report for the documentation example [...]
Button[lable, Dynamic[action]]added to usage. Briefly mentioningButtonFunctionwill probably be missed or will confuse a user who is unaware of subtleties. – Kuba May 26 '16 at 20:36Buttoninserts styling options even though it's a basicButton? I mean,Appearanceis inserted what makes impossible to putBaseStyle->ButtonBoxOptions->Appearance->_outside and hope that it will be inherited. Or maybe the best way is to work withRawBoxes + controllerBoxso that one can usecontrollerBoxOptionsto style them collectively? – Kuba May 26 '16 at 20:45Appearanceoption...well, there is a reason, but I'm not sure it's a very justifiable one. Basically, it was a hack to deal with the default options we wanted forButtonin v6 without breaking backward compatibility withButtonBoxes that were generated pre-v6. It's a decision which seemed sensible (albeit a bit hacky) at the time, but looks increasingly silly today. I would be willing to call the current behavior a minor bug. – John Fultz May 28 '16 at 00:06