How to detect ALT-C or Control-C?

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 cor.

#C_Code=100

The following is in the event menu
AddkeyboardShortCut(0, #PB_ShortCut_C, #C_Code)

It's working if I press C key, but how to detect CTRL-C?

AddkeyboardShortCut(0, #PB_ShortCut_C | #PB_ShortCut_Control, #C_Code) does not work.



Using Windows 98 SE
Registered PB version : 3.2 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.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 fweil.

Hello cor,

Don't know how you coded it in your test but the following works fine ...

As I use Debug to display result, do not forget to select the window back itself after program's start.

;==========================================
WEvent.l
EventMenu.l
Quit.l

Quit = #FALSE
If OpenWindow(0, 0, 0, 320, 240, 0, "")
AddKeyboardShortcut(0, #PB_Shortcut_Escape, 99)
AddKeyboardShortcut(0, #PB_ShortCut_C, 100)
AddKeyboardShortcut(0, #PB_ShortCut_C | #PB_ShortCut_Control, 101)
AddKeyboardShortcut(0, #PB_ShortCut_C | #PB_Shortcut_Alt, 102)
AddKeyboardShortcut(0, #PB_ShortCut_C | #PB_ShortCut_Control | #PB_Shortcut_Alt, 103)
Repeat
WEvent = WaitWindowEvent()
Select WEvent
Case #PB_EventMenu
EventMenu = EventMenuID()
Select EventMenu
Case 99
Quit = #TRUE
Case 100
Debug "C"
Case 101
Debug "CTRL-C"
Case 102
Debug "ALT-C"
Case 103
Debug "ALT-CTRL-C"
Default
EndSelect
Default
EndSelect
Until Quit
EndIf

End
;==========================================


Francois Weil
14, rue Douer
F64100 Bayonne
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 Fangbeast.
Originally posted by cor

#C_Code=100

The following is in the event menu
AddkeyboardShortCut(0, #PB_ShortCut_C, #C_Code)

It's working if I press C key, but how to detect CTRL-C?

AddkeyboardShortCut(0, #PB_ShortCut_C | #PB_ShortCut_Control, #C_Code) does not work.
Hello Cor, hope you don't mind me saying that I can see that you had it backwards, the control key check must come first, then the key or'ed with it.

AddkeyboardShortCut(0, #PB_ShortCut_Control | #PB_ShortCut_C, #C_Code)

I have many keyboard shorcuts through most of my apps since I learned how to use it properly (I can hear Paul laghing at me now) and that's the right way around.

@Francois, I don't see how yours can work backwards like that, it isn't logical, sounds like my normal mode of thinking!! (grin)

Fangles
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 Danilo.

Hehe... "#PB_ShortCut_Control | #PB_ShortCut_C"
is a simple bitwise OR, so the order doesnt
make any difference.

Did Paul teach you that ?? :)

cya,
...Danilo

(registered PureBasic user)
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 Fangbeast.
Originally posted by Danilo

Hehe... "#PB_ShortCut_Control | #PB_ShortCut_C"
is a simple bitwise OR, so the order doesnt
make any difference.

Did Paul teach you that ?? :)

cya,
...Danilo

(registered PureBasic user)
Didn't know about the order, I supposed it was a FIFO storage buffer.

As for Paul, he was teaching me native Canadian sarcasm :):)

Just remembering from 18 years ago that alot of the P'code and interpreted languages used a strictly first in-first out logic for tests (unlike multi-pass and single pass assembly compilers of today) so that Control and then C was the way it was tested and not the other way around

Does anyone remember the Sharp handheld, the Sega and the Exidy Sorcerer computers?? Their Basics were great :):)
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 cor.

Thanks for the responses.

My first code was ok. There was something wrong with the event handling. Its working now.

Using Windows 98 SE
Registered PB version : 3.2 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.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 fweil.

Allright ... This allowed to learn that Canadian sarcasm exist ...

Easy guys. I love this forum and discussions we have.

Francois Weil
14, rue Douer
F64100 Bayonne
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 Fangbeast.
Originally posted by fweil

Allright ... This allowed to learn that Canadian sarcasm exist ...

Easy guys. I love this forum and discussions we have.

Francois Weil
14, rue Douer
F64100 Bayonne
Look at Danilo's smiley character and my ":):)" and if you think that smiling is scary, you should hear the way Paul and I stir each other, it's very funny :) Everyone should download Paul's PB chat program and have some live fun :):)

Fangles
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 fweil.

I was not used to smileys before starting with PB forum (maybe a bit old to have been teached with that before). But I am looking now messages here and I agree this may become funny for experts.

...

Francois Weil
14, rue Douer
F64100 Bayonne
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 Fangbeast.

We sometimes forget to put them in!!!

Fangles
Post Reply