nomad-software / tkd

GUI toolkit for the D programming language based on Tcl/Tk
MIT License
117 stars 16 forks source link

Tab key produces a script error instead of tabbing to next widget #22

Closed ghost closed 10 years ago

ghost commented 10 years ago

I get this error even if I add .setKeyboardFocus(KeyboardFocus.normal) to buttons

invalid command name "tk_focusNext"

nomad-software commented 10 years ago

Can you explain how i can recreate this error please? Also check you have linked to the correct version of the Tcl/Tk libraries.

ghost commented 10 years ago

I'm using Dub to build. I assume I have correct libraries. I am on win7. and using latest beta. put a couple of buttons on a form and hit the tab key. It should tab from the exit button to the about button, unless I am misunderstanding what is supposed to happen: If you have a command prompt window open you can see the TCL errors display

    auto exitButton = new Button(buttonFrame,"Exit")
        .focus
        .setKeyboardFocus(KeyboardFocus.normal)
        .pack();

    auto aboutButton = new Button(buttonFrame,"About")
        .setKeyboardFocus(KeyboardFocus.normal)
        .pack();
nomad-software commented 10 years ago

I've just tested your example on Window 7, building with dub and everything works fine.

I assume I have correct libraries.

How did you install the Tcl/Tk libraries? Are you using the ActiveTcl library mentioned in the readme or are you using the DLLs supplied in the tcltk repo?

ghost commented 10 years ago

Hi Gary I have TKD 1.0.6 beta. TCLTK 8.6.2 and I am not using active state install. I build TKD with just 'DUB'. I put tkd.lib file in the folder with my main.d and the three dll's in the tcltk dist x86 folder. I compile with DMD 2.065 the following. DMD main.d tkd.lib.

Everything works except the tabbing thing. It appears to me that the two things it is looking for are in the tcl scripts. "tk_focusNext" and "TabToWindow"

I will try downloading ActiveState and try it, and let you know what happens Thanks Dave

ghost commented 10 years ago

It works with ActiveState install. Which brings me to the following question. Can I use what is distributed with TKD without worrying about ActiveState license? I.e. do the TCL scripts in TKD belong to ActiveState? I can build TCL DLL's myself, I read where that is OK,

ghost commented 10 years ago

I really need to distribute without requiring an activestate install if possible, I was reading the scripts license.terms file, and it makes it sound like it is ok to use the scripts however I need. Active state license is pretty straitforward that it requires purchase if using it commercially

ghost commented 10 years ago

Ha! found the problem. tclindex.tcl in your distribution is missing the entries for focus.tcl I cut and pasted and it works!

nomad-software commented 10 years ago

Right thanks, i'll take a look and remove anything from ActiveTcl in the tcltk repo. I'll update the library too. I'll compile Tcl myself and include those DLL's. Stay tuned!

ghost commented 10 years ago

Cool. Thanks Gary

nomad-software commented 10 years ago

Ok i've sorted out the files and everything works nicely on x86 and x64 but i need to wait until the new version of dub is out until i can release a new version that uses these new libraries. Purely because the new version of dub allows me to copy across the libs during build. I don't want people building something then scratching their heads why a missing dll error appears :)

nomad-software commented 10 years ago

I noticed there was a lot of Tk missing from tclIndex so i've added it all. If you want to get your hands on it now you can see master here: https://github.com/nomad-software/tcltk I'll do a proper release of this when the new version of dub is out.

ghost commented 10 years ago

I'll do it, I understand the dub issue. I got plenty to do for a while, not a problem on waiting.

I hope you don't mind me firing issues at you! I got another one. The Text widget is not a "themed" widget so it does not respond to setState. It lets you call setState but just silently ignores what you tell it to do. I was trying to make a text widget read only and it was not working. it was silently ignoring the setState. I caught it in the debugger, and then saw that I could turn tcl error display on by passing the debug command to it, and it then told me that "state" was an invalid command.

I read the following - http://wiki.tcl.tk/1152 then I made a little subclass to get around it.

class MyText : Text { this(UiElement parent) { super(parent); }

public void ReadOnly(bool disabled)
{
    if(disabled)
    {
        this._tk.eval("%s configure -state disabled", this.id);
    }
    else
    {
        this._tk.eval("%s configure -state normal", this.id);
    }
}

}

Later Dave

On Wed, May 21, 2014 at 3:53 PM, Gary Willoughby notifications@github.comwrote:

I noticed there was a lot of Tk missing from tclIndex so i've added it all. If you want to get your hands on it now you can see master here: https://github.com/nomad-software/tcltk I'll do a proper release of this when the new version of dub is out.

— Reply to this email directly or view it on GitHubhttps://github.com/nomad-software/tkd/issues/22#issuecomment-43805638 .

nomad-software commented 10 years ago

Added method to the text widget. https://github.com/nomad-software/tkd/commit/fc3d2d09284f3a7a3462e5bfd42edb47320da247

nomad-software commented 10 years ago

I'll marked this as fixed as i'll release the changes when a new release of dub is done.