Lisp HUG Maillist Archive

Push on - push off

Hi Lispers!

I would like to have a button which toggles between a normal and a pressed state when clicked. As far as I can tell, this is not possible with CAPI (pity!)

But is there some workaround, platform-specific or otherwise?

One way to create the button in Cocoa is something like

(make-instance 'capi:cocoa-view-pane
               :visible-min-width 70  ; size needs to be specified explicitly
               :visible-min-height 30
               :view-class "NSButton"                                           
               :init-function #'(lambda (pane view)
                                  (setq view (objc:invoke view "init"))
                                  (objc:invoke view "setButtonType:" 1)
                                  (objc:invoke view "setTitle:" "Button title")
                                  (objc:invoke view "setBezelStyle:" 1)
                                  view))

But then I can't (easily at least) catch click events to the button (is it even possible to do it from LW?).

Any ideas?

Regards
Erik

Re: Push on - push off

I forgot to say: I am aware of the possibility to use check-buttons with images, but that is not what I'm after. I would like a button that have the native button look-and-feel of the platform.

Regards
Erik


20 okt 2011 kl. 21:30 skrev Erik Ronström:

Hi Lispers!

I would like to have a button which toggles between a normal and a pressed state when clicked. As far as I can tell, this is not possible with CAPI (pity!)

But is there some workaround, platform-specific or otherwise?

One way to create the button in Cocoa is something like

(make-instance 'capi:cocoa-view-pane
               :visible-min-width 70  ; size needs to be specified explicitly
               :visible-min-height 30
               :view-class "NSButton"                                           
               :init-function #'(lambda (pane view)
                                  (setq view (objc:invoke view "init"))
                                  (objc:invoke view "setButtonType:" 1)
                                  (objc:invoke view "setTitle:" "Button title")
                                  (objc:invoke view "setBezelStyle:" 1)
                                  view))

But then I can't (easily at least) catch click events to the button (is it even possible to do it from LW?).

Any ideas?

Regards
Erik


Re: Push on - push off

Unable to parse email body. Email id is 11355

Re: Push on - push off


On Oct 20, 2011, at 5:54 PM, Erik Ronström wrote:

> However, we are developing an application for both Windows and MacOSX, and I was hoping to find a cross-platform solution.

You can't use a push button as a toggle and hope for it to be cross platform because using a push button to indicate state is a violation of the Apple Human Interface Guidelines for Mac OS X. IOW, Apple explicitly tells developers *not* to use a button as a state toggle, which is what you want to do. You're fighting both LispWorks CAPI *and* Apple here. You're supposed to use a checkbox instead:

"Do not use a push button to indicate a state, such as on or off. Instead, you can use checkboxes to indicate state, as described in “Checkbox.”"

from:
<http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Controls/Controls.html#//apple_ref/doc/uid/TP30000359-TPXREF104>

So, according to Apple, if you want your app to have the native look and feel of Mac OS X you should be using a capi:check-button (the capi equivalent of a Cocoa checkbox), *not* a capi:push-button.

warmest regards,

Ralph


Raffael Cavallaro
raffaelcavallaro@me.com






Updated at: 2020-12-10 08:37 UTC