Pushbutton size

I’m creating a control set dynamically in my app. Each entry on screen has 2 controls, an entry field and a push button. The push button is essentially a delete option, the user presses it the entry field and button are removed and any on screen gaps are closed up. The button is a small round one with a minus sign in it. When I originally wrote this a few years ago I could only configure a bevel button to get the look I wanted.
The delete process is fairly complex and I now need to be able to do it from a couple of locations inside the app and I don’t want to replicate that code. I decided to use the pushbutton Press method. A bevel doesn’t have a Press method so I changed it to a push button which can now be configured with the look I want, and it promptly disappeared from the IDE.
When I ran the program the button was there but vertically about twice its height from where the IDE said it should be.
I’ve created a window with no code just a bevel and push button and the behaviour is the same.
I this how it’s supposed to work?

For avoiding code duplication, you could also have opted for moving your code into a method and calling the method from every location (nitpicking: yes, you’d call the method from several places and that may be called “duplicate code”, but that’s still a good way).

You changed its “super” property or you created a brand new control?
If the former, that’s bad practice: properties of the old type may interfere with the new type and corrupt the control.

No; a control appears at the same location in the IDE and running app, normally. Something else’s going on…
Have you tried with only a push button in a blank project? Then only a bevel button? And, finally, with, say, a label? If all these fail, there’s a serious problem in your Xojo installation.

I changed the Super to a push button, just to prevent me having to copy and paste the events. When that misbehaved I created a push button from scratch and that misbehaved as well.
I created a window that has only a push button, a bevel button and an entry field on it. Both buttons are configured Round and 20 pixels wide. The bevel displays where I expected it and the push is above its defined location. If I change it to a “normal” button it displays where it should.
I was going to include a screenshot, but I don’t see how you do that in the forum now.

Screenshot1 is the IDE. The pushbutton is the selected control, the bevel alongside it.
Screenshot2 is the running app.

You may want to file a feedback over this, I don’t know why changing the button style should change it’s vertical position.

There are 3rd Party toolkits you can use to also accomplish this.

I’d also like to mention that with Big Sur, Apple has started to use a new “destructive” style for buttons (it basically makes the label red in color). It’s only available in a few instances (and not directly from Xojo either). I am hoping that Apple rolls it out to other parts of the UI as I like the idea of a “destructive” style that people will learn.

I’ve faked it here, and added my own “Delete Confirmation” popover for when people click on the destructive button.

1 Like

OK … Thanks for that.
I’ve logged the issue in the Feedback app.


1 Like