Comments (9)
What about <Control-Key-a>
?
from tkd.
Nope, doesn't work.
However, if I do the following:
private void selectText(CommandArgs args) {
this._clientId.selectText;
this._clientPass.selectText; // <-- added selectText for client password Entry
}
this._loginFrame = new Frame(2, ReliefStyle.groove);
this._clientId = new Entry(this._loginFrame).grid(0, 0);
this._clientId.bind("<Control-a>", &selectText);
this._clientPass = new Entry(this._loginFrame).grid(0, 1); // <-- added client password Entry
Somehow, when I hit <Control-a>
while being in the client id Entry widget, the client password Entry widget gets its text selected and client id widget moves the cursor to the start of the Entry (default Tk behavior) 😮
Here is a screenshot:
from tkd.
Hmmm... strange. I might take a closer look at this tomorrow when I have more time. It looks like it should work, without seeing the rest of your program it's hard to tell though. Try creating a small standalone full program to test to rule out something else interfering with it.
from tkd.
I've only just started so there isn't much code, here is a test sample:
import std.stdio;
import std.format;
import tkd.tkdapplication;
class App : TkdApplication
{
private Frame _loginFrame;
private Entry _clientId;
private Entry _clientPassword;
private string[string] credentials;
private void exitApplication(CommandArgs args)
{
this.exit();
}
private void youForgotMsg(string msg)
{
auto youForgot = new MessageDialog(this.mainWindow, "Error").setIcon(MessageDialogIcon.warning)
.setMessage("Ooops!").setDetailMessage("You forgot %s!".format(msg)).show;
}
private void selectText(CommandArgs args)
{
this._clientId.selectText;
this._clientPassword.selectText;
}
private void getClientCredentials(CommandArgs args)
{
if (!this._clientId.getValue)
{
this.youForgotMsg("client Id");
}
else if (!this._clientPassword.getValue)
{
this.youForgotMsg("client password");
}
else
{
this.credentials["client_id"] = this._clientId.getValue;
this.credentials["client_password"] = this._clientPassword.getValue;
this._loginFrame.destroy;
}
}
private void createClientLoginWindow(int outerPadding)
{
// Create client login frame
this._loginFrame = new Frame(2, ReliefStyle.groove);
auto label1 = new Label(this._loginFrame, "Client ID").grid(0, 0);
this._clientId = new Entry(this._loginFrame).grid(1, 0, 5);
this._clientId.bind("<Return>", &getClientCredentials);
this._clientId.bind("<Control-a>", &selectText);
auto label2 = new Label(this._loginFrame, "Password").grid(0, 1);
this._clientPassword = new Entry(this._loginFrame).grid(1, 1, 5);
this._clientPassword.bind("<Return>", &getClientCredentials);
//this._clientPassword.bind("<Control-a>", &selectText);
this._loginFrame.grid(0, 0, outerPadding);
}
override protected void initInterface()
{
this.mainWindow.setTitle("Tester");
this.mainWindow.setMinSize(300, 200);
this.mainWindow.setProtocolCommand(WindowProtocol.deleteWindow, delegate(CommandArgs args) {
this.exitApplication(args);
});
this.createClientLoginWindow(10);
}
}
void main()
{
auto app = new App();
app.run;
}
from tkd.
I've taken a look and i'm stumped. It looks like the callback is firing correctly but the selection is failing for some reason. There also looks to be another binding for <Control-a>
on the Entry
because it places the cursor at the start of the text when triggered. I'm out of ideas.
from tkd.
I've taken a look and i'm stumped. It looks like the callback is firing correctly but the selection is failing for some reason. There also looks to be another binding for
<Control-a>
on theEntry
because it places the cursor at the start of the text when triggered. I'm out of ideas.
Yep. Tk has its own default bindings and <Control-a>
puts cursor to the beginning while <Control-/>
selects text.
The same behaviour in Python Tkinter and I don't remember if you can rebind there either.
I have found this so post.
from tkd.
I found my old Tkinter code that tackles this problem. I am going to try this with D tomorrow.
def ctrl_a(self, callback=False):
"""
Select all in entry or text widget.
Overwrite tkinter default 'ctrl+/' keybind.
"""
# checking which text widget has focus
if self.Entry is self.focus_get():
self.Entry.select_range(0, 'end')
elif self.Text is self.focus_get():
self.Text.tag_add('sel', '1.0', 'end')
return 'break'
# (...)
self.Entry.bind('<Control-a>', self.ctrl_a)
from tkd.
Well, I was overly optimistic about it. It's not possible because .bind
expects void function. I guess it's a bug then.
from tkd.
I'm going to archive this repository as it's not supported by me anymore.
from tkd.
Related Issues (20)
- Build of example fails on Mac OSX 10.11 HOT 1
- Text bind (<<Modified>>) only happens once HOT 3
- Example fails to run on Windows but build fine HOT 1
- Add note for linker flags in windows needed to prevent console window. HOT 2
- commandCallbackHandler catches Throwable making unrecoverable Errors impossible HOT 5
- lib found but undefined references HOT 5
- start TK in D Programming ! HOT 4
- Feature Request: add OpenGL capabilites HOT 4
- Changing Widget Background Color HOT 3
- MDI Support HOT 3
- Color methods have been added to widgets that can't use them
- does canvas use the gpu to draw? HOT 1
- Error: module `tkdapplication` is in file 'tkd\tkdapplication.d' which cannot be read HOT 4
- Windows requires Microsoft Visual C++ Redistributable HOT 2
- How to install this in Windows ? HOT 3
- Segmentaiton Fault after Choosing a File via OpenFileDialog HOT 2
- How can I get currently selected tab in NoteBook widget? HOT 1
- Has this been abandoned? HOT 3
- Simple Q: is the final app using this lib completely native? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tkd.