# How do I change the pressed button appearance?

On my system when a default button is pressed it turns light blue. This appearance can be changed using this code from the documentation:

Use a second element to get the appearance of a pressed button:

Table[Button["xxx", Null, Appearance -> {a, "Pressed"}], {a, {"DialogBox", "Palette"}}]


So in essence you change the pressed button appearance by changing the button appearance. But if you want no appearance, i.e. Appearance->None, you are still stuck with the blue background:

Button["xxx", Null, Appearance -> {None, "Pressed"}]


I can achieve what I want using EventHandler:

EventHandler[MouseAppearance["xxx", "LinkHand"],"MouseClicked" :> Print["X"]]


But it seems to me that I should be able to do this with Button options.

Q. How can I set appearance to None for both the pressed and unpressed button? If this cannot be done with button options--and it would seem an oversight if it is not possible--I will use EventHandler.

-
why not use Appearance -> None i.e., without the "Pressed" option? –  The Toad Jun 11 '12 at 1:52
@R.M because when pressed it still gives the pressed style. That is the whole reason for this question ;) –  Mike Honeychurch Jun 11 '12 at 1:53
Is this OS X specific? If yes, can you please tag with macosx? –  Szabolcs Jun 13 '12 at 7:20
@Szabolcs I use Mac OS X. I do not know the behaviour on Windows ...but that does not mean it differs on Windows. The answer I got from tech support did indicate any platform specificity. –  Mike Honeychurch Jun 13 '12 at 11:24

Based on a guess, I just tried "Disabled" in the appearance, and it worked:

Button["xxx", Null, Appearance -> {"Disabled", "Pressed"}]


However, it seems that this "non"-appearance results even if I replace "Disabled" by "". So maybe putting in the empty string is enough for your purposes.

Edit:

Since I can't guess an option value that works without producing a (harmless but annoying) frontend warning message in the console, maybe one could do the following. It's also a hack, but it produces "no appearance" while still using the functionality of Button (as opposed to the EventHandler approach which is actually easier but which wasn't desired):

Graphics[Button[Text["xxx"], Print[x]], ImageSize -> {50, 10},
ContentSelectable -> False]


This produces a completely bland

$\text{xxx}$

that still works as a button, without having the "inverse-video" effect when the mouse is clicked. Now the downside is that you may have to adjust the ImageSize and/or font size of the button.

-
Using "Disabled" generates an error in the messages window: "The specified setting for the option ButtonBoxOptions, Appearance cannot be used." You can get the same appearance even with Appearance -> {"blah", "Pressed"} –  The Toad Jun 11 '12 at 1:46
Enabled->False switches off the functionality which is not what I want. The empty string seems to work. –  Mike Honeychurch Jun 11 '12 at 1:49
@R.M. is right - you do get a message in the message window, even for "". Maybe there's a better way - this was basically dumb luck. –  Jens Jun 11 '12 at 1:54
Yes I hadn't cleared the message window. I can see now that an empty string produces the message as well. –  Mike Honeychurch Jun 11 '12 at 1:57
@MikeHoneychurch How about the new hack I added? Not exactly user-friendly, but as close as I can seem to get... –  Jens Jun 11 '12 at 4:13

(from Wolfram tech support)

There is no direct way of doing this but the work around is to set the button appearance to "Pressed" and set the button background to the inverse of the background you actually want. So for a white button:

Button["xxx", Print@"test", Appearance -> {None, "Pressed"}, Background -> Black]


This gives you a button that does not change its background colour when pressed which is what I was looking for.

-
That's easy enough. So you'd use Background -> Blue if you really want a yellow background, etc.... But my solution (with Graphics) also works when you don't use appearance "Pressed", whereas with this work-around here you can really only keep the button in the pressed state, because the non-pressed one will now have the inverse color. –  Jens Jun 13 '12 at 0:35
@Jens. Yes it stays in the pressed state. I don't care so much about that because I wanting Appearance->None in both pressed an unpressed states. Actually I decided to go with EventHandler in my code. These works arounds are simple enough but I think EventHandler is much easier for others to read and see what is going on and why it is there. –  Mike Honeychurch Jun 13 '12 at 0:48