Search code examples
smalltalksqueak

How to change the auto completion button in squeak?


is there a way to change the shortcut to invoke auto completion in the squeak vm (standard is tab)?

Thanks in advance


Solution

  • (I assume you use OCompletion or ECompletion)

    The only way to change this currently is to change the code.

    OController>>handleKeystrokeBefore: kbEvent editor: theEditor 
        "I return a boolean. true when I have handled the event and no futher processing is needed by the caller."
        | keyValue ctrl cmd down tab colon alphanum del esc enter up |
        self editor: theEditor.
        self setModel: theEditor model.
        keyValue := kbEvent keyValue.
        ctrl := kbEvent controlKeyPressed.
        cmd := kbEvent commandKeyPressed.
        down := keyValue = 31.
        up := keyValue = 30.
        tab := kbEvent keyCharacter = Character tab. "<-- change this to your desired key"
        enter := kbEvent keyCharacter = Character cr.  
        colon := kbEvent keyCharacter = $:.
        alphanum := kbEvent keyCharacter isAlphaNumeric.
        "..."
    

    Or, when you only use ECompletion

    ECController>>handleKeystrokeBefore: aKeyboardEvent editor: anEditor 
        "I return a boolean. true when I have handled the event and no futher processing is needed by the caller."
    
        | theEditor keyValue controlKeyPressed isSpaceKey |
        self editor: anEditor. 
        theEditor := self editor.
        self setModel: theEditor model.
        keyValue := aKeyboardEvent keyValue.
        controlKeyPressed := aKeyboardEvent controlKeyPressed.
        isSpaceKey := #(0 32 ) includes: keyValue.
        "Ctrl-Space or Tab for open"
        self isMenuOpen
            ifFalse: [(isSpaceKey & controlKeyPressed
                        or: [keyValue = 9 "            <-- change this to your desired key"
                                and: [theEditor isCaretBehindChar
                                        and: [controlKeyPressed not]]])
        "..."