Menu shortcuts?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Naitfreak.

How do I create shortcuts for my menus? I mean like "Ctrl+N". I tried AddKeyboardShortcut() but it didn't work.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

AddKeyboardShortcut() works for me. Can you post an example?

El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Naitfreak.

Well, not really. All I can say is that when I insert this line "AddKeyboardShortcut(MainWin,#PB_Shortcut_C | #PB_Shortcut_Control,1)" PB completely crashes.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

What are you taking as MainWin ?

Is it the Value you get with WindowID(), or the one you use with OpenWindow like OpwnWindow(MainWin, ...

It has to be the one from Openwindow, the PureBasic Window Number, not the ID (or handle) it gets from Windows.

Maybe this causes the crash.

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Naitfreak.

Yup! That caused the crash! I used the wrong value for the '#window' variable. It works now.

But how can I integrate the visual shortcut like "Crtl+N" into the actual graphical representaion of the menu? I mean it's not done by simply but this next to the name of the specific menu item when you create it. It will look pretty disordered and will remain on wrong places when the width of the menu changes. Like when you have recent file list in your menu.

Is that possible at all?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Berikco.

use something like this

"New"+Chr(9)+"Ctrl+N"

Regards,

Berikco

http://www.benny.zeb.be/purebasic.htm
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Hi-Toro.

Use Chr (9) [tab] to separate the 'Ctrl X' strings, like this:

Code: Select all

OpenWindow (0, 320, 200, 320, 200, #PB_Window_SystemMenu, "Test")

CreateMenu (0, WindowID ())
MenuTitle ("&File")
MenuItem (1, "Open file..." + Chr (9) + "Ctrl O")
MenuItem (2, "Save file..." + Chr (9) + "Ctrl S")
MenuItem (3, "Read a really good book before going to bed..." + Chr (9) + "Ctrl R")
MenuItem (4, "Exit..." + Chr (9) + "Ctrl E")

Repeat

Until WaitWindowEvent () = #PB_Event_CloseWindow
End

--
See ya,
James L Boyd.
http://www.hi-toro.com/
--
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TheBeck.

I think this kind of stuff should be in the manual. I spent several hours trying to solve this very problem recently. I only figured it out by examining the PureBasic editor source code.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Kale.

The forum search gave me this, you should try the search function first, its very helpful :):
viewtopic.php?t=2571

--Kale

In love with PureBasic! :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Naitfreak.

Adding 'Chr(9)' works wounders for me. Thank's a bunch but as TheBeck pointed out this should really be added/updated in PB manual.

Lata~
Post Reply