It is currently Fri Dec 13, 2019 9:34 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: [Done] Problem with menu shortcut CMD+Z
PostPosted: Thu Nov 30, 2017 2:49 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 472
I write my own undo history, but I can't assign CMD+Z as menu shortcut.

Code:
Global Window_0

Enumeration menu
  #Menu_Undo
EndEnumeration


Procedure OpenWindow_0(x = 0, y = 0, width = 450, height = 160)
  Window_0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CreateMenu(1, WindowID(Window_0) )
  MenuTitle("Edit")
  MenuItem(#Menu_Undo, "Undo"+Chr(9)+"Cmd+Z")
EndProcedure

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False
     
    Case #PB_Event_Menu
      Select EventMenu()
        Case #PB_Menu_Quit
          ProcedureReturn #False
        Case #Menu_Undo
          Debug "UNDO"
      EndSelect
     
  EndSelect
  ProcedureReturn #True
EndProcedure

OpenWindow_0()

Repeat
  event = WaitWindowEvent()
Until Window_0_Events(event) = #False

End


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem with menu shortcut CMD+Z
PostPosted: Thu Nov 30, 2017 9:32 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1658
Location: Germany
Wolfram wrote:
but I can't assign CMD+Z as menu shortcut.

Confirmed on MacOS 10.9.5 'Mavericks' with PB 5.45 in ASCII and Unicode mode and with PB 5.61. Selecting the menu entry "Undo" is detected but not pressing <Cmd>+<Z> or <Cmd>+<z>. The combination <Cmd>+<X> or <Cmd>+<Y> is detected correctly.


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem with menu shortcut CMD+Z
PostPosted: Sun Dec 03, 2017 8:04 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 472
Is it a PB bug or a problem of OSX?


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem with menu shortcut CMD+Z
PostPosted: Mon Dec 04, 2017 12:46 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2009
Location: USA
That's because there's no #PB_Menu_Undo for OS X. You're going to have to create a keyboard shortcut, like so. ;)

Code:
Global Window_0

Enumeration menu
  #Menu_Undo
EndEnumeration


Procedure OpenWindow_0(x = 0, y = 0, width = 450, height = 160)
  Window_0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CreateMenu(1, WindowID(Window_0) )
  MenuTitle("Edit")
  MenuItem(#Menu_Undo, "Undo"+Chr(9)+"Cmd+Z")
  AddKeyboardShortcut(Window_0, #PB_Shortcut_Command | #PB_Shortcut_Z, #Menu_Undo)
EndProcedure

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False
     
    Case #PB_Event_Menu
      Select EventMenu()
        Case #PB_Menu_Quit
          ProcedureReturn #False
        Case #Menu_Undo
          Debug "UNDO"
      EndSelect
     
  EndSelect
  ProcedureReturn #True
EndProcedure

OpenWindow_0()

Repeat
  event = WaitWindowEvent()
Until Window_0_Events(event) = #False

End

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem with menu shortcut CMD+Z
PostPosted: Mon Dec 04, 2017 10:43 am 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 472
Hello J. Baker,

this looks like a workaround to me.
Normally I can create a shortcut directly in the menu like
Code:
MenuItem(#Menu_Undo, "Undo"+Chr(9)+"Cmd+Z")

This works with every key/key combination but not with CMD+Z.

What's the reason of the problem?


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem with menu shortcut CMD+Z
PostPosted: Mon Dec 04, 2017 7:22 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2009
Location: USA
Wolfram wrote:
Hello J. Baker,

this looks like a workaround to me.
Normally I can create a shortcut directly in the menu like
Code:
MenuItem(#Menu_Undo, "Undo"+Chr(9)+"Cmd+Z")

This works with every key/key combination but not with CMD+Z.

What's the reason of the problem?

You are correct. I had forgotten about that. Maybe Fred had a reason for that or it just wasn't added by accident. :wink:

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem with menu shortcut CMD+Z
PostPosted: Mon Dec 04, 2017 8:52 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1658
Location: Germany
Wolfram wrote:
This works with every key/key combination but not with CMD+Z.

It seems to be a bug in PureBasic because the documentation for MenuItem clearly states:
On OS X, when a shortcut is created in the menu, there is no need to call the AddKeyboardShortcut() function with this shortcut.


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem with menu shortcut CMD+Z
PostPosted: Fri Apr 26, 2019 4:44 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13659
Location: France
Fixed.


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem with menu shortcut CMD+Z
PostPosted: Fri Apr 26, 2019 6:57 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1688
Quote:
It seems to be a bug in PureBasic because the documentation for MenuItem clearly states:
On OS X, when a shortcut is created in the menu, there is no need to call the AddKeyboardShortcut() function with this shortcut.


I never knew this! :shock:

_________________
On GitHub: PB Includes - IDE Tools - Color Themes


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye