Making an invisible button appear when cursor is in its bounds

Hi,

I am interested to know if it is possible to create an invisible button that appears when the cursor hovers on its top.

I have tried the “mouse entered” handler then connect the button (invisible on awake from nib) to the handler in the Interface Builder but I can’t make it to do anything…make the button visible or even just showing a dialog statement just to test if the handler is working.

Any kind help is greatly appreciated.

archseed

Hi Jacques,

I tried to verify your suggestion to use a background custom view (NSView) over the buttons but it still doesn’t do anything.

I think my problem lies with the main window not being the original window. I adapted Jonn’s titlelessWindow in my little app which basically builds a new window without the title over the original main window. The buttons in the new window only respond to clicks. I could actually make the buttons do something when tied to the “on mouse entered” handler but using another window which points out the problem.

Is there a specific property that should be recaptured from the original window by the new window to get the buttons to behave as if they were still in the original window? I tried to check this but I can’t single anything out.

BTW, the buttons do not even respond to the keyboard commands that I set up in the Interface Builder…basically the same problem.

Thanks.

archseed :frowning:

Hi Jacques,

Just want you to know that despite modifying the codes according to your latest suggestion, the buttons still do not respond to “mouse entered” handler.

I actually adopted the latest version of Jonn’s titlelessWindow. Somehow, the buttons respond only to click. Even providing the keyboard shortcut in the IB does not do anything. There must be something missing in the custom window that makes it immune to any mouse movement over its buttons.

Will keep trying but if any of you out there know of anything that would address the problem, would appreciate your help.

archseed :frowning:

I can confirm that Jacques modified version of my project does in deed work – with a caveat (I compiled and ran it on Xcode 2.2/Mac OS X 10.4.3). The caveat: sometimes the custom box seems to respond to the “mouse exited” behavior rather than “mouse entered” handler (the “mouse exited” handler was not linked to this item). By this I mean it doesn’t show the hidden button when the mouse moves into the custom box’s zone but only when it moves out of the zone. It’s minor because essentially the code works, a button can be hidden and when a user mouses over the area (and then out), the button appears.

Jon

Hi Jon,

Thanks a lot for the info.

I am still on Xcode 2.0 and can’t verify if the problem is with compiling in an older version. Xcode is a humungous download and I am on dial-up. Will check that when I have access to v2.2.

Keep up your great work of helping the rest of us. Everyone’s help in this forum is much appreciated.

archseed :slight_smile:

Hi,

This is an update - with thanks to Jon and Jacques.

Yes, your suggestions do work to make my invisible buttons show up when mouse hovers above. I did upgrade finally to Xcode 2.2. However, I think my problem was because of the silly mistake to have the “on mouse entered” handler linked to the wrong object instead the NS view (Sorry about this. I hope it did not mislead others.)

Incidentally, I have not had any problem yet with the 'caveat" you mentioned. The “mouse entered” handler works seamlessly, thus far. I also have the NS view attached to an “on mouse exited” handler so that when I move the cursor out of it the visible buttons disappears. Cool!

Many thanks for the suggestions.

archseed :slight_smile: