Equivalent to Push() Method for BevelButton?

Is there a way to simulate a click (push) event for the BevelButton? The standard PushButton has the Push() method but I want to use a BevelButton for various design reasons. Thank you!

Do you actually want to PUSH the button?
or do you want to perform the same action that would occur if the user pushed the button?

if so, then in the ACTION for the BevelButton put

Sub Action() Handles Action
End Sub

put the code for what you want done in “doSomething”

and where you want to “simulate” the push, simply call “doSomething”

Dave - thanks! This is what I will end up doing…moving the code in the button’s Action event to a method and calling it that way. I am sure this is methodology would fall into “best practices” anyway.

Definitely a best practices move. Because now, when you add your MenuHandler and your Toolbar that does the exact same thing you have the method to do it. FWIW I use HandleSomething for my naming but whatever makes sense for you.

I’ve always hated the Pushbutton.Pushed method - but I suspect it was put in because a lot of VB6 code had that functionality.

FWIW you might want to avoid Bevel buttons on macOS

and the reason?

Does Xojo not use NSBUTTON for both Bevel and Pushbutton controls?

A solution, but not a best practice. The designers should have a kind o .PushButton(), because this way they can encapsulate visual behaviors. Calling DoSometing() directly will skip the internals for that object behavior like:

[code]// This is internal code
// MyButton.PushButton fires DoSomething() with all the visual fxs associated
Public Sub Button.PushButton()

// This is your code
Private Sub MyButton.Action()

Private Sub MyButton.DoSomething()


I will tend to disagree. The UI should control the “business logic”, and never the other way around.
And when ever possible the code for the “business logic” should be as divorced from the UI as possible,

[quote=438104:@Dave S]and the reason?
Does Xojo not use NSBUTTON for both Bevel and Pushbutton controls?[/quote]
Apparently not https://forum.xojo.com/50528-darkmode-bevelbuttons
Plus Apple recommends not using bevel buttons https://developer.apple.com/design/human-interface-guidelines/macos/buttons/bevel-buttons/

And it is. But you wont lose the native visual fx of you alien platform being emulated. Mac, Android, Windows, WeirdOS…

Don’t be confused with the parts “Framework” and “User” I’ve simulated.

Norman, the link you gave in Xojo forum is private. There isn’t any alternative when we want a small button with a single character.

Or maybe a single segmented button? But the ability to have a Popup in the BevelButton is a good thing too.

its a pre-release thread from 2018r3
basically the control used for bevel buttons is not mojave friendly so you might want to avoid it
I’m not aware that has changed in subsequent releases

as for a replacement - its a handful of lines of code in a canvas subclass to get the majority of the functionality

And in case you are not familiar with it, you can highlight a block of code (say most/all the code in your button’s event) then right click and “Convert to Method”. A little less work and error prone then the steps you’d do manually.

After which you can call that new method in other spots where you want to perform the same code.

If you want a small button with a single character, simply use a push button and an emoji for the text. On Mac, this is very straightforward and can be Dione using the “show emoji and symbols” keyboard top right of the screen. . Not sure how well this translates to a windows environment.