How to rebind the default tkd GUI keybinds?

starcanopy starcanopy at protonmail.com
Sat Oct 17 18:39:54 UTC 2020


On Saturday, 17 October 2020 at 09:33:04 UTC, tastyminerals wrote:
> On Sunday, 11 October 2020 at 18:51:17 UTC, tastyminerals wrote:
>> Tk default keys are somewhat different from what we used to 
>> use for selecting, copying and pasting the text. So, any Tk 
>> based GUI app starts with writing the rebinding function for 
>> "ctrl+a", "ctrl+c", "ctrl+x" and "ctrl+v" keys, at least. I 
>> did it when writing TkInter based apps in Python. Today I am 
>> trying out tkd and want to do the same. However, it doesn't 
>> work :(
>>
>> For example:
>>
>> private void selectText(CommandArgs args) {
>>     this._clientId.selectText;
>> }
>>
>> this._loginFrame = new Frame(2, ReliefStyle.groove);
>> this._clientId = new Entry(loginFrame).grid(1, 0);
>> this._clientId.bind("<Control-a>", &selectText);
>>
>> It works if I change "<Control-a>" to "<Control-o>" for 
>> example.
>> But how do I overwrite the actual "<Control-a>" key in tkd?
>
> So, this is even tricky in Python TkInter but possible.
> In tkd this is not possible unfortunately.

You could try directly calling 
[bindtags](https://www.tcl.tk/man/tcl8.4/TkCmd/bindtags.htm) with 
_tk.eval. Modifying and extending tkd is easy from my experience 
where I had added support for additional image formats. (After 
blundering about on how to get tcl/tk to work, lol.)


More information about the Digitalmars-d-learn mailing list