Escape

Discuss GUI programming with the MUI Royale plugin here
Post Reply
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Escape

Post by ArtBlink »

Hello

When i use ESC key, the muiroyale programm quit

I have add in my script

EscapeQuit(False)

It don't work, i can always quit my program when i press ESC touch

But, with this :

CtrlCQuit(False)

CTRL+C touch don't quit my programm

How i can desactivate ESC touch for MUIRoyale programm please?

Thanks

;-)
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Escape

Post by airsoftsoftwair »

Escape quit in MUI applications is managed by MUI, not by Hollywood. That's why EscapeQuit() doesn't have any effect here. I don't think it's possible to disable escape quit in MUI without going to major pains like hooking into the keyboard handler.
User avatar
tboeckel
Posts: 38
Joined: Fri Jun 06, 2014 6:17 am
Location: Germany

Re: Escape

Post by tboeckel »

airsoftsoftwair wrote:Escape quit in MUI applications is managed by MUI, not by Hollywood. That's why EscapeQuit() doesn't have any effect here. I don't think it's possible to disable escape quit in MUI without going to major pains like hooking into the keyboard handler.
Sorry, but this is nonsense. MUI does in no way use the Esc key to quit an application. By default the Esc key is configured to set the window's MUIA_Window_CloseRequest attribute to TRUE, nothing more, nothing less. This can be changed on the Keyboard page of MUI prefs, either globally or individually for each application. However, usually there is this line of code:

Code: Select all

DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
This single line is responsible for letting a MUI application quit itself in case the window is requested to be closed. But this is part of the application code. Obviously Hollywood applications seem have this automatism built in. MUI is not guilty here.
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Escape

Post by airsoftsoftwair »

Well, that's basically what I meant by saying "escape quit in MUI applications is managed by MUI". Of course, you're right that it doesn't explicitly quit on escape but by default it hooks the escape key (or whatever key the user has configured) to the window's close event and AFAICS there is no simple way for an application to tell MUI to only set MUIA_Window_CloseRequest when the user clicks the window's close gadget and not when he pressed the user-configurable hotkey.
User avatar
tboeckel
Posts: 38
Joined: Fri Jun 06, 2014 6:17 am
Location: Germany

Re: Escape

Post by tboeckel »

airsoftsoftwair wrote:Well, that's basically what I meant by saying "escape quit in MUI applications is managed by MUI". Of course, you're right that it doesn't explicitly quit on escape but by default it hooks the escape key (or whatever key the user has configured) to the window's close event and AFAICS there is no simple way for an application to tell MUI to only set MUIA_Window_CloseRequest when the user clicks the window's close gadget and not when he pressed the user-configurable hotkey.
Wrong again. Every application has the choice how to react on a window close request. Closing a window does in no way require an application to quit. The fact that all of MUI's demos will quit the application if the window is closed is just for easyness of the demos. An application which requires saving of yet unsaved stuff will ask the user for confirmation if the window's close gadget is clicked before it proceeds. And how it proceeds is still up the application. MUI does not dictate the further progress in any way.

What about these two lines of code?

Code: Select all

DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, window, 3, MUIM_Set, MUIA_Window_Open, FALSE);
DoMethod(quitButton, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
Clicking the window's close gadget (or pressing Esc) will just close (or better: hide) the window, but the application will stay alive. However, the special "Quit" button will really terminate the application. You see there is no relationship between closing a window and terminating an application. It is up to the developer to either set up this relationship or to implement other ways of terminating the application. MUI does not enforce anything here.
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Escape

Post by airsoftsoftwair »

tboeckel wrote: Wrong again. Every application has the choice how to react on a window close request. Closing a window does in no way require an application to quit. The fact that all of MUI's demos will quit the application if the window is closed is just for easyness of the demos. An application which requires saving of yet unsaved stuff will ask the user for confirmation if the window's close gadget is clicked before it proceeds. And how it proceeds is still up the application. MUI does not dictate the further progress in any way.
[...]
Clicking the window's close gadget (or pressing Esc) will just close (or better: hide) the window, but the application will stay alive. However, the special "Quit" button will really terminate the application. You see there is no relationship between closing a window and terminating an application. It is up to the developer to either set up this relationship or to implement other ways of terminating the application. MUI does not enforce anything here.
Appears you have misread my remarks. The question here is: Is there any way to detect whether MUIA_Window_CloseRequest was triggered by the user pressing the hotkey or by the user clicking the window's close gadget? This would be a prerequisite for implementing what the OP wants.
User avatar
tboeckel
Posts: 38
Joined: Fri Jun 06, 2014 6:17 am
Location: Germany

Re: Escape

Post by tboeckel »

airsoftsoftwair wrote:Appears you have misread my remarks. The question here is: Is there any way to detect whether MUIA_Window_CloseRequest was triggered by the user pressing the hotkey or by the user clicking the window's close gadget? This would be a prerequisite for implementing what the OP wants.
You don't need to care for the reason why MUIA_Window_CloseRequest is triggered. You also don't care what causes a button to be pressed. This can be done by mouse or by keyboard. But in any case MUIA_Pressed will be set to FALSE to indicate a click on that button. The close request can even be triggered artifically by just set()ing it. MUI does not remember any details about what is causing the trigger of a certain attribute, because in principle all triggers boil down to a code line like "set(object, attribute, value)".

The close request is exactly what it name says: a request to close the window, nothing else. If and how an application reacts on this request is up to the application. MUI does not impose anything here, and this is what this discussion is about.

"Esc" is simply the default key to trigger a close request for a window by keyboard. This can be changed by the user to anything else. Even "Return" can be used. However, if that is a sensible setting is a completely different matter.

Another possibility is to set MUIA_Window_DisableKeys to ignore certain standard keys:

Code: Select all

set(window, MUIA_Window_DisableKeys, 1<<MUIKEY_WINDOW_CLOSE);
This will disable the standard "Esc" sequence to trigger a close request. From that point on the close request can only be triggered by clicking the close gadget or by

In general it is a bad idea to disable standard keys, because people expect their key definitions to work always and in all situations. So better think more than twice if you really intend to use this feature.
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: Escape

Post by djrikki »

Don't fully understand the broken English question being asked, but in your event handler, listen for CloseRequest and when its received just state mui.Set('WNME','open', True) thus nothing the window remains. And like tbroekel says, simply closing the last remaining Window doesnt close the App - it remains open in the background as a running Commodity, Exchange shows this clearly.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
Post Reply