Page 1 of 1

quit app by dock or mac-menu

Posted: Tue Feb 14, 2012 10:01 pm
by delikanli_19_82
there is a problem,

if i want to quit the app by the mac-dock or from the applications's menu, where the app-name is topic by choose the entry called "Quit...", it doesn't respond.

how can i solve this problem?

please help :-)

Re: quit app by dock or mac-menu

Posted: Tue Feb 14, 2012 10:08 pm
by WilliamL
I'm not sure I understand what you are asking but if the app you created is not responding you can always go to the Apple menu and use 'Force Quit".

Re: quit app by dock or mac-menu

Posted: Tue Feb 14, 2012 10:57 pm
by Polo
Use the predefined constant #pb_menu_quit :)

Re: quit app by dock or mac-menu

Posted: Tue Feb 14, 2012 11:26 pm
by WilliamL
Yeah, good thought Polo,
'-pre defined constants of #PB_Menu_About, #PB_Menu_Preferences,#PB_Menu_Quit'
http://www.purebasic.fr/english/viewtop ... 19&t=45613

Re: quit app by dock or mac-menu

Posted: Wed Feb 15, 2012 10:23 am
by delikanli_19_82
hello guys,

i couldn't find a solution yet. here a better description:

think the application's name is "my_app". if you start my_app, you get it's menu at the top of the screen, beside the apple-logo.

if you click on the my_app-name, it pulls out a popup-menu. at the bottom of the popup-menu there is a entry called "Quit...". if you click on it, the my_app should end, but don't.

a second method is, if you click longer then one second on the my_app-icon in the dock. a popup-menu also pulls out. also there you can click on a option called "Quit" to quit the application.

i am using a german surface, therefore i am not sure, if the option is called "Quit" or "Close" in the english original.

the #pb_event_closewindow is normally used in code to finish the application. if you click on the red colored close-button of the window itself, the app finishs. if i try one of the described ways above, it doesn't works. i have no idea, why...

i need help :-)
please help :-)

Re: quit app by dock or mac-menu

Posted: Wed Feb 15, 2012 10:34 am
by Polo
We gave you the solution!

Re: quit app by dock or mac-menu

Posted: Wed Feb 15, 2012 10:47 am
by delikanli_19_82
ok, i found something to solve this problem.

...
if e = #pb_event_menu and eventmenu() = #pb_menu_quit
end
endif
...

thanks

:-)

Re: quit app by dock or mac-menu

Posted: Wed Feb 15, 2012 6:16 pm
by WilliamL
Ok, I see what you are saying. You may have already figured it out but...something like this.

[edit] It looks like I asked this same question 4 years ago. http://www.purebasic.fr/english/viewtop ... 19&t=34046 :)

Code: Select all

If OpenWindow(0, 0, 0, 230, 90, "Event handling example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If CreateMenu(0, WindowID(0))
        MenuTitle("File")
        MenuItem(1, "One")
        MenuItem(2, "Two")
        MenuItem(#PB_Menu_Quit, "Quit")
    EndIf 

    Repeat
        Event = WaitWindowEvent()
        Select Event
        Case #PB_Event_Menu
            MenuID=EventMenu() : Debug MenuID
            Select MenuID
            Case #PB_Menu_Quit
                End
            EndSelect
        EndSelect
    Until Event = #PB_Event_CloseWindow
 EndIf

Re: quit app by dock or mac-menu

Posted: Sun Feb 19, 2012 8:38 am
by delikanli_19_82
programming means also studying. you could never know everything. sometimes also so simple things.

thanks again :-)