www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to rebind the default tkd GUI keybinds?

reply tastyminerals <tastyminerals gmail.com> writes:
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?
Oct 11 2020
parent reply tastyminerals <tastyminerals gmail.com> writes:
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.
Oct 17 2020
parent reply starcanopy <starcanopy protonmail.com> writes:
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.)
Oct 17 2020
parent tastyminerals <tastyminerals gmail.com> writes:
On Saturday, 17 October 2020 at 18:39:54 UTC, starcanopy wrote:
 On Saturday, 17 October 2020 at 09:33:04 UTC, tastyminerals 
 wrote:
 On Sunday, 11 October 2020 at 18:51:17 UTC, tastyminerals 
 wrote:
 [...]
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.)
So, there is a way. It just needs substantial time investment :) Thanks for point it out.
Nov 25 2020