No it should be the cancel button but in some cases (when my canvas has the focus) I want to prevent the cancel button to be fired.
I thought handling the KeyDown for myself would be enough but I think I have to check the focus of my canvas in the action event of the cancel button.
The question is if this is a bug or not?
Why is this not an option???
A “cancel” button IS an ordinary button with “CANCEL” as the caption, but with a built-in event… …and event that you do not wish to occur… So why try and make it do something it isn’t made to do? The “Cancel” button is provided as a convience for when it is appropropriate, in this case it is not.
and in your previous post you contradict yourself.
[quote]Click on the cancel button --> window should close[quote]
earlier you said
how about when you do not wish the cancel button to be used, simply disable it?
I don’t think its a bug per se more of a feature that needs to be programmed around.
ESC to close a window is pretty standard on macos and windows. If you dont want it to happen, uncheck the Cancel Boolean for the button and handle it in your own WIndow1.KeyDown event. This event will only fire is nothing else intercepts/handles the key stroke, for example, when your canvas doesn’t have focus.
Or, you could keep it as it is, and have a bool for focus tracking on your canvas, set the bool to true when your canvas has focus and false when it loses focus, then in your Cancel button, only perform an action when this bool is false (ie. when focus is not on the canvas).
Or, you could set PushButton1.Cancel = False in Canvas1.GotFocus and PushButton1.Cancel = True in Canvas1.LostFocus
The ESC to trigger a Cancel button is a thing on Mac though, so we should figure out the expected behavior and file a feedback case. I appreciate how if I’ve got a form on a sheet window with a Cancel button that even if a TextField has focus the Cancel button can still be fired. This is how it’s supposed to work for me, and I do not want this to change.
So, to me, the OP’s project is exhibiting a bug on macOS, since the Canvas is consuming the ESC/Cancel.
Yup, I saw the same issue but I don’t use macos enough to know what is regarded as standard behaviour there. I just figured macos was right (as almost everything come from there first) and as it was different to Windows then it was windows that was “wrong”. if someone puts in the ticket, just make then aware its different on the two platforms and to come to some agreement between the two, whichever they fix is in the hands of the gods devs.