Re: Shortcut (key equivalent)
Quote from Forum Archives on February 10, 2022, 10:47 amPosted by: paboyle1703 <paboyle1703@...>
On Feb 10, 2022, at 09:52, Bernie <[email protected]> wrote:
Working my way through Ari's nice utilities (welcome Ari!), I was wondering how he'd configured the user-preferred shortcut button (textfield?) in his Dusk app's preferences window.Below is my attempt at emulating it. Improvements welcome.btw, I wish I knew the unicode value for Apple's return key symbol. The one with the square hook.<SquaredHook.png>The closest I can come is u21A9 but indicators in the documentation suggest that the display is dependent on the default font selected. I doubt that Apple will let you know which font they are using. I did think that unicode displays were fixed and universal, but from the documentation that does not seem to be the case for arrows (Wikipedia)
/*Shortcut ButtonClick the button to make it the target for key presses.Click anywhere else to remove focus.*/_window = 1begin enum 1_shortcutLabel_shortcutBtn_clearBtnend enumvoid local fn BuildWindow'~'1subclass window _window, @"Shortcut", (0,0,480,360)textlabel _shortcutLabel, @"Shortcut", (134,173,57,16)subclass button _shortcutBtn,,, @"⌃⌘/", (190,163,100,32)button _clearBtn,,, @"", (291,173,15,15)ButtonSetBordered( _clearBtn, NO )ButtonSetImage( _clearBtn, NSImageNameStopProgressFreestandingTemplate )end fnlocal fn CharacterForKeyCode( keyCode as unsigned short ) as CFStringRef'~'1CFStringRef chr = NULLCFStringRef keyCodeCharacters = @"ASCFHGZXCVu00A7BQWERYT123465=97-80]OU[IPu21A9LJ'K;\,/NM.u21E5u2420`u232B"select ( keyCode )case 53 : chr = @"u241B" // esccase 123 : chr = @"u25C0" // left arrowcase 124 : chr = @"u25B6" // right arrowcase 125 : chr = @"u25BC" // down arrowcase 126 : chr = @"u25B2" // up arrowcase elseif ( keyCode < len(keyCodeCharacters) )chr = mid(keyCodeCharacters,keyCode,1)end ifend selectend fn = chrvoid local fn ShortcutBtnKeyDown'~'1NSEventModifierFlags modifiers = fn EventModifierFlagsunsigned short keyCode = fn EventKeyCodeCFStringRef string = fn CharacterForKeyCode( keyCode )if ( string )if ( modifiers and NSEventModifierFlagCommand ) then string = fn StringByAppendingString( @"⌘", string )if ( modifiers and NSEventModifierFlagOption ) then string = fn StringByAppendingString( @"⌥", string )if ( modifiers and NSEventModifierFlagControl ) then string = fn StringByAppendingString( @"⌃", string )if ( modifiers and NSEventModifierFlagShift ) then string = fn StringByAppendingString( @"⇧", string )button _shortcutBtn,,, stringend ifend fnvoid local fn DoDialog( ev as long, tag as long, wnd as long )'~'1select ( ev )case _btnClickselect ( tag )case _clearBtnbutton _shortcutBtn,,, @""end selectcase _viewMouseDownselect ( tag )case _shortcutBtnWindowMakeFirstResponder( _window, tag )end selectcase _viewKeyDownselect ( tag )case _shortcutBtnfn ShortcutBtnKeyDownDialogEventSetBool(YES) // we handledend selectcase _windowMouseDownselect ( tag )case _windowWindowMakeFirstResponder( _window, 0 )end selectend selectend fnfn BuildWindowon dialog fn DoDialogHandleEvents
--
To unsubscribe, send ANY message to: [email protected] To access the list archives, go to: http://freegroups.net/groups/futurebasic/
Peter BoyleFB 7.0.11OSX 10.14.6Xcode 10.2iMac 21.5 Late 20152.8 GHz Intel Core i5
--
To unsubscribe, send ANY message to: [email protected] To access the list archives, go to: http://freegroups.net/groups/futurebasic/
Posted by: paboyle1703 <paboyle1703@...>
On Feb 10, 2022, at 09:52, Bernie <[email protected]> wrote:
Working my way through Ari's nice utilities (welcome Ari!), I was wondering how he'd configured the user-preferred shortcut button (textfield?) in his Dusk app's preferences window.Below is my attempt at emulating it. Improvements welcome.btw, I wish I knew the unicode value for Apple's return key symbol. The one with the square hook.<SquaredHook.png>
The closest I can come is u21A9 but indicators in the documentation suggest that the display is dependent on the default font selected. I doubt that Apple will let you know which font they are using. I did think that unicode displays were fixed and universal, but from the documentation that does not seem to be the case for arrows (Wikipedia)
/*Shortcut ButtonClick the button to make it the target for key presses.Click anywhere else to remove focus.*/_window = 1begin enum 1_shortcutLabel_shortcutBtn_clearBtnend enumvoid local fn BuildWindow'~'1subclass window _window, @"Shortcut", (0,0,480,360)textlabel _shortcutLabel, @"Shortcut", (134,173,57,16)subclass button _shortcutBtn,,, @"⌃⌘/", (190,163,100,32)button _clearBtn,,, @"", (291,173,15,15)ButtonSetBordered( _clearBtn, NO )ButtonSetImage( _clearBtn, NSImageNameStopProgressFreestandingTemplate )end fnlocal fn CharacterForKeyCode( keyCode as unsigned short ) as CFStringRef'~'1CFStringRef chr = NULLCFStringRef keyCodeCharacters = @"ASCFHGZXCVu00A7BQWERYT123465=97-80]OU[IPu21A9LJ'K;\,/NM.u21E5u2420`u232B"select ( keyCode )case 53 : chr = @"u241B" // esccase 123 : chr = @"u25C0" // left arrowcase 124 : chr = @"u25B6" // right arrowcase 125 : chr = @"u25BC" // down arrowcase 126 : chr = @"u25B2" // up arrowcase elseif ( keyCode < len(keyCodeCharacters) )chr = mid(keyCodeCharacters,keyCode,1)end ifend selectend fn = chrvoid local fn ShortcutBtnKeyDown'~'1NSEventModifierFlags modifiers = fn EventModifierFlagsunsigned short keyCode = fn EventKeyCodeCFStringRef string = fn CharacterForKeyCode( keyCode )if ( string )if ( modifiers and NSEventModifierFlagCommand ) then string = fn StringByAppendingString( @"⌘", string )if ( modifiers and NSEventModifierFlagOption ) then string = fn StringByAppendingString( @"⌥", string )if ( modifiers and NSEventModifierFlagControl ) then string = fn StringByAppendingString( @"⌃", string )if ( modifiers and NSEventModifierFlagShift ) then string = fn StringByAppendingString( @"⇧", string )button _shortcutBtn,,, stringend ifend fnvoid local fn DoDialog( ev as long, tag as long, wnd as long )'~'1select ( ev )case _btnClickselect ( tag )case _clearBtnbutton _shortcutBtn,,, @""end selectcase _viewMouseDownselect ( tag )case _shortcutBtnWindowMakeFirstResponder( _window, tag )end selectcase _viewKeyDownselect ( tag )case _shortcutBtnfn ShortcutBtnKeyDownDialogEventSetBool(YES) // we handledend selectcase _windowMouseDownselect ( tag )case _windowWindowMakeFirstResponder( _window, 0 )end selectend selectend fnfn BuildWindowon dialog fn DoDialogHandleEvents
--
To unsubscribe, send ANY message to: [email protected] To access the list archives, go to: http://freegroups.net/groups/futurebasic/
--
To unsubscribe, send ANY message to: [email protected] To access the list archives, go to: http://freegroups.net/groups/futurebasic/