How to get a bevel button to close a window

The normal push button has a button.push action
Is there an equivalent for bevel buttons?

I want to open a window, display a msgBox if certain conditions aren’t met and then close the window from the code that displays the msgBox.

It works fine with a standard push button, but can’t figure out how to do it with a bevel button. Do I have to write a method to close the window and then call it?
Thanks

Here’s the documentation for BevelButton: http://documentation.xojo.com/index.php/BevelButton
Take a look through the events, and implement an Event Handler for the one you desire.

Thanks
Already took a look at that. I am trying to do something like: remote window.cancelbutton.push, where cancel button has scope across the application.
There is no “push” action for a bevel button that allows me to make it do something from another window. Do I have to implement this myself? I thought of writing a method “closeWindow” that simply does “self.close”, but it seems a bit silly - surely there is a way to activate a bevel button from another window?

Ah, I see where we’re misunderstanding each other. I thought you were looking for the correct Action event.
The design you are going for is very dangerous (in terms of habits) and encourages spaghetti code.

If all the button does is close the window then remoteWindow.Close would do the trick.
If there are other actions before the button closes the window your CloseWindow method implementation is what you will need to do.

Push accomplishes 2 things, it gives a visual indication of the button being pressed and also calls the action event. If you’re not concerned about the visual aspect, create a global method “close_this_specific_window()” and then call it from wherever you want, including the action event of your bevelbutton.

Thank you both for the feedback. I realise this can be considered a dodgy approach, but is necessary in this instance, as I don’t want the user to be able to edit a record if a certain condition is not met, and want to drop them back to the calling window as soon as the error message is displayed.

I now have a clear idea of what to do.

Shouldn’t there be a “push” method in the BevelButton class? It exists in the PushButton Class. Or maybe I am not taking into account the other features of the bevel button that makes it difficult to implement it.

Anyway, thanks again.

I hope that means refactoring so that if the user isn’t allowed to edit the record nothing happens at all :wink:

That is what happens now with a push button. Hope to change that to a bevel button with the same functionality.

[quote=364760:@Philip Cumpston]Thank you both for the feedback. I realise this can be considered a dodgy approach, but is necessary in this instance, as I don’t want the user to be able to edit a record if a certain condition is not met, and want to drop them back to the calling window as soon as the error message is displayed.

I now have a clear idea of what to do.

Shouldn’t there be a “push” method in the BevelButton class? It exists in the PushButton Class. Or maybe I am not taking into account the other features of the bevel button that makes it difficult to implement it.

Anyway, thanks again.[/quote]

why don’t you check the condition first on the calling window and give the message and don’t even open the pop up instead of opening the pop up screen and check the condition and then give message and close

hmmm,
that is an interesting idea - will give it a go.
Thanks