Overlapping buttons - Why?

See https://forum.xojo.com/60599-overlapping-buttons-not-showing-up

Why would you ever need overlapping buttons or move buttons around? Couldn’t you just change the Caption and act accordingly? What am I missing here?

I’ve been working on a Windows port of a client project and what works simply & easily on macOS may not work at all on Windows
I’ve rewritten big chunks of code to account for the differences and its not fun
This project does a lot of moving controls around and hiding / showing them and on macOS things look fine & drawing works.
On Windows not so much as its sensitive to z-order and many other things in ways macOS just doesnt seem to care about

The latest one is HTML Viewer wit canvases over them to try & capture drops of pictures & other items
Works dandy on macOS and in this project as soon as I do that the viewer becomes obscured. I can put the canvas over half the html viewer and half of it will appear
Doesnt matter about transparency etc

Its not fun

Yes, but BUTTONS? There is simply no need to overlap two buttons in the same place.

I would agree
But if you just use the action event of a button to put all your code in then having to buttons with two different action event implementations is a straight forward and seemingly simple way to attack this
That seems to be the authors original thinking

If the two buttons have significantly different caption widths and you use one control you could end up with one of them looking weird unless you resize the button using code.

I personally think it is cleaner to have separate buttons for each action and you then set the position and visibility.

Remember, Xojo doesn’t come with much of a manual anymore. Tips and tricks like “You don’t need two buttons for that” are things we learned the hard way :slight_smile:

Best thing to do is share the advice and help people watch out for things that secretly make the project harder.

In my case the action code is in the MouseUp event handler. Easier to move the button around than figure out how to alter the MouseUp code at runtime.

This just doesnt always work so well in several cases in Windows - esp if you expect it to composite like macOS. Toss in the new pseudo transparency and blech !
I dealt with this in the IDE for 10 years and am working through many of these same issues in a clients port to Windows

Just my 2 cents

In a button ? Thats what the action event already does when you use any of the button types
Maybe I’m misunderstanding ?

There are lots of handy dandy ways to change what gets runs dynamically
Select case/if then else checking the caption is just one

The button is in fact a canvas tarted up to look like the macOS BevelButton.

I could use a select case to choose the action, it would have 31 entries, but the upside would be all the MouseUp event handlers could be moved into the Class.

Won’t be doing it on this iteration but I could look at that if I’m bored one day :innocent:

AH - so yes you would want the action to happen in mouse up

I wrote a pretty complete replacement for the bevelbutton because of the issues with dark mode & macOS bevelbuttons

You could use a delegate attached to the buttons tag property & just invoke that since they’d all be no param delegates

I sense a blog post about stuff like this … :stuck_out_tongue:

Maybe we are talking about two different things as I don’t understand why there would be problems.

Our logic decides which button is required, moves it to the correct place and makes it visible while at the same time making the other button invisible (we might also be multiplying the top * -1 so that it is off the window).

it works in nice simple cases where all you want to do is hide & show another button but there are others where it wont work or wont work well
z-order matters as well esp on Windows
otherwise you can have issues
if you expect to move controls like this “onto” and “off of” a canvas that scrolls controls you can have issues

I wonder whether the OP is coming from Filemaker Pro - it’s fairly common in FMP to have objects with apparently altered states and hiding/showing some of them based on a condition…

Clearly doesn’t apply to any other environment :slight_smile:

I dont know that they said at all in that thread