I found a definition of a button

Button[Defer[ Information[ \[SelectionPlaceholder], LongForm -> False]], 
  None, BaseStyle -> "CopyEvaluate"]

that is doing a good job.

How can I add a label to this button definition similar to Button[label, action]? I have trid to change the definition given above, but nothing I've done worked.

  • 1
    $\begingroup$ You are using a special pre-defined button style that gives special treatment to your button's label (Defer[Information[\[SelectionPlaceholder], LongForm -> False]]) is the label). This means you can't just add a lable to it. What you can do, if anything, to get the effect you want, I haven't figured out. $\endgroup$ – m_goldberg Aug 9 '13 at 0:47
  • $\begingroup$ @Liam. Button works fine on my system. $\endgroup$ – m_goldberg Aug 9 '13 at 0:49
  • $\begingroup$ @m_goldberg check edit history it didn't $\endgroup$ – William Aug 9 '13 at 1:03
  • $\begingroup$ I don't get it.. what is this button supposed to do? It looks like all it does is to print Information[#, LongForm -> False] when you press it. $\endgroup$ – bill s Aug 9 '13 at 2:33
  • $\begingroup$ It is an interesting problem if I have got it right. It appears to be able to give information about a selected text when the button is clicked! I agree with @m_goldberg that we are dealing with a button that uses a style and a special kind of label therefore I thought about using Interpretation or going to a more low-level function as ButtonBox. But, by now, I have nothing. My tests with Interpretation change the label but render the button useless. $\endgroup$ – Ailton Andrade de Oliveira Aug 9 '13 at 2:45

If you want to use BaseStyles like "CopyEvaluate" etc I'm afraid you have to stick to that:

Button[label,None,BaseStyle->stylename] inherits button functionality from the definition of stylename in thestylesheet. Such styles typically allow \[SelectionPlaceholder] to be used in label to represent the currently selected text.

So it is just the matter of the construct. However, you can mimic this behaviour:

        "the best label",

enter image description here

| improve this answer | |

This is very slightly better, perhaps?

Help[s_] := Information[s, LongForm -> False];
Button[Defer@Help[\[SelectionPlaceholder]], None, 
    BaseStyle -> "CopyEvaluate"]

animated gif

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.