Author Topic: wxKeyBinder problems/solutions discussion  (Read 19706 times)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2784
wxKeyBinder problems/solutions discussion
« on: December 09, 2005, 06:13:33 pm »
I''ve been wadeing in wxKeyBinder crashes for two days now. Man, they're
the same ones I encountered when fooling around with a cbKeyBinder
plugin a month ago. Pernicious little buggers.

1) frames/buttons etc. appear and disappear without keybinder knowledge
2) Menu items appear and disappear without keybinder knowledge
3) keybinder has memorized all the disappearing frames and wxMenuItems.
4) keybinder is memorizing items it should be filtering out (buttons/dividers...)
5) There are items created by code::blocks that blow wxWidgets out
    of the water when manipulated by keybinder (Maybe this is item2 in
    disguise).

Solutions: (Maybe)

1) Dont allow keybinder to memorize windows it isnt explicity told about
    via an array of "names" or window_handles.
    Mostly taken care of by cbEvt_(open/close events) already.
2) Institute a cbEvt_Menu_HasChanged(id) event so keybinder can
    clean out its old memorized items that are disappearing.
3) Taken care of by #1.
4) Taken care of by #1 and #2
5)  More confirmation needed to see if wxWidgets wxMenuItem->GetLabel()
     is actually being confused by "\" chars in filenames, or its just that the
     menu item disappeared.

Just my thoughts.
I'd love to work on it with some direction of course.

thanks
pecan
« Last Edit: December 09, 2005, 06:15:43 pm by Pecan »

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: wxKeyBinder problems/solutions discussion
« Reply #1 on: December 09, 2005, 06:50:57 pm »
If you want my thoughts on wxKeyBinder, having used it for about a month now, I believe it's not up-to-par (at least for C::B). It's a good library for smaller/simpler projects but not for C::B.
I think we should begin an implementation discussion for commands/actions, like what Takesh Miya started at this topic.
Be patient!
This bug will be fixed soon...

takeshimiya

  • Guest
Re: wxKeyBinder problems/solutions discussion
« Reply #2 on: December 09, 2005, 07:03:57 pm »
I couldn't agree more :lol:

If something like that gets implemented, I'll love to see it available as a standalone too, so we could use it in other projects appart from C::B.
Making it a wx contrib, and perhaps calling it wxCommandBinder or wxActionBinder. :P

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: wxKeyBinder problems/solutions discussion
« Reply #3 on: December 09, 2005, 07:06:05 pm »
I couldn't agree more :lol:

If something like that gets implemented, I'll love to see it available as a standalone too, so we could use it in other projects appart from C::B.
Making it a wx contrib, and perhaps calling it wxCommandBinder or wxActionBinder. :P

I just hope you have time to work on it ;)
Be patient!
This bug will be fixed soon...

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2784
Re: wxKeyBinder problems/solutions discussion
« Reply #4 on: December 09, 2005, 07:14:03 pm »
mandrav

I certainly agree. wxKeyBinder was not designed for as dynamic
an environment as C::B. I think you'd have to yank it out within
another version anyway.

A better way, I think, is for C::B to be the "server" for a bunch of
keybinder type plugins. C::B could provide the services AND
verifications/validations for
1) a menu keybinder plugin
2) a key macros plugin eg. {Ctrl-Enter} = {\n}{Tab}{Tab}{or whatever}
3) or a scintilla recorder event server thingie so a plugin could record the movements to a file
4) scripting (already planned I've read)

ie, dont pollute the main C::B code with jobs that a plugin can do. Just
provide the means so a plugin can do the job. With events for example.

Anyway, if you want to yank the keybinder code, I'll
re-implement the keybinder plugin as a stopgap measure.
Then when a "real" solution arrives, the plugin can be disposed of.

But to make the stopgap keybinder plugin really workable,
we'll still need the cbEvt_MenuChanged(id) event so that
keybinder can get rid of disappearing menu items from it profile arrays.

I've solved the disappearing windows/frames problem by only alllowing
keybinder to attach() via an array of know windows.

What do ya think

thanks
pecan

takeshimiya

  • Guest
Re: wxKeyBinder problems/solutions discussion
« Reply #5 on: December 09, 2005, 07:26:35 pm »
I just hope you have time to work on it ;)

Unfortunately I don't have the skills yet =(

A better way, I think, is for C::B to be the "server" for a bunch of
keybinder type plugins. C::B could provide the services AND
verifications/validations

Yes, something like that is more or less what I had in mind, but in a paradigm of "commands" and "bindings".
Thus, you could provide a "command" cmdSaveFile, and you could bind it to a menu, or a keyboard, or a mouse gesture.

And suppose you write an AngelScript macro that when you press {Ctrl-Enter} = {\n}{Tab}{Tab}. You could call that function (command) cmdCtrlEnter.

And then you could bind it to a menu entry, toolbar icon, etc.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2784
Re: wxKeyBinder problems/solutions discussion
« Reply #6 on: January 11, 2006, 12:40:49 am »
1/10/2006 6:28 PM

Have commited KeyBinder v0.4.8 (svn 1708)
 
Fixed disappearing accerators when two menuitems have
the same label.

Fixed potential crash when panels are destroyed.

You may have to delete cbKeybinder04v16.ini from your
home directory if you get messages like "Keybinder file is corrupt, please delete".

This is because the code started honoring/matching the menuitems' id if the
text field *and* id match the file data. That way menuitems with identical text
can be differentiated. Eg., File->save project vs Project->save project.

You guys trying to throw curve balls again..?
It ain't gonna work. I may be the slowest turtle in the pond, but I
can tread water forever....

thanks
pecan
« Last Edit: January 11, 2006, 02:19:33 am by Pecan »

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: wxKeyBinder problems/solutions discussion
« Reply #7 on: January 11, 2006, 07:06:03 pm »
...Have commited KeyBinder v0.4.8 (svn 1708)...
you've used wxMenuItem::SetFont & ::GetFont
these are windows-only ! your plugin doesn't build under linux  :(

Code
menuutils.cpp: In member function 'void wxMenuCmd::RebuildMenuitem()':
menuutils.cpp:162: error: 'class wxMenuItem' has no member named 'SetFont'
menuutils.cpp:162: error: 'class wxMenuItem' has no member named 'GetFont'

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2784
Re: wxKeyBinder problems/solutions discussion
« Reply #8 on: January 11, 2006, 07:15:33 pm »
Sorry

I should have surrounded that routine with #if defined( __WXMSW__ )

Will correct and recommit. Thanks for the heads up...

thanks
pecan

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: wxKeyBinder problems/solutions discussion
« Reply #9 on: January 11, 2006, 07:34:44 pm »
I should have surrounded that routine with #if defined( __WXMSW__ )
i fear, that will not be enough ...

that'll be the result...  :?

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2784
Re: wxKeyBinder problems/solutions discussion
« Reply #10 on: January 11, 2006, 07:44:30 pm »
1/11/2006 1:42 PM

Have commited KeyBinder v0.4.9 (svn 1718)

Set invalid window ptr flag for wxBinderEvtHandler to avoid
using closed window pointer.

Surrounded menuitem rebuild code with #ifdef __WXMSW__

thanks tiwag
pecan

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2784
Re: wxKeyBinder problems/solutions discussion
« Reply #11 on: January 11, 2006, 07:52:59 pm »
@tiwag

Quote
i fear, that will not be enough ..

ok, I see
will fix this sortly

thanks
pecan

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2784
Re: wxKeyBinder problems/solutions discussion
« Reply #12 on: January 11, 2006, 08:37:35 pm »
1/11/2006 2:35 PM

Have commited KeyBinder v0.4.10 (svn 1719)

Separated out and demangled the GTK menuutils::Update()
menuitem update code.

thanks
pecan

Edit: I only have 5 more hrs of downloading to get ISO ubuntu.
    Then I can test the GTK stuff. Thanks tiwag
« Last Edit: January 11, 2006, 08:45:06 pm by Pecan »

atwins

  • Guest
Re: wxKeyBinder problems/solutions discussion
« Reply #13 on: January 11, 2006, 11:58:13 pm »
I submitted this as a bug report (1402208), but I just did a rebuild and see you have it handled. Good job,

Oh yeah,  and if you are downloading the CD iso for ubuntu, you can count on doing a bunch more.  It doesn't come with development stuff.  But once GTK2 and GCC and G++ and a decent editor (oops, you can use Code::Blocks!!) etc. it is sweet.  My favorite.

Thanks again for fixing this. 



Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: wxKeyBinder problems/solutions discussion
« Reply #14 on: January 12, 2006, 11:14:53 am »
Have commited KeyBinder v0.4.10 (svn 1719)

Separated out and demangled the GTK menuutils::Update()
menuitem update code.

thx pecan !  the menu items are clean now using wxGTK !

but there exists another problem, i can't save any new keyboard settings,

after applying the changes, keybinder pops up a messagebox, saying the
new keyboard layout is saved under "/home/tiwag//.codeblocks/cbKeyBinder04v16.ini"
but there is no such file existing :?

after you've OK'ed this dialog, a codeblocks error-message pops up, saying
11:05:21 AM: Failed to create a temporary file name (error 2: No such file or directory)
11:05:21 AM: can't open user configuration file.


did you notice the double slashes in the directory-path   /home/tiwag//.codeblocks  ?

it seems, that this
Code
    //memorize the key file name as {%HOME%}\cbKeyBinder+{vers}.ini
    m_sKeyFilename = ConfigManager::GetConfigFolder();
    // remove the dots from version string (using first 3 chars)
    wxString sPluginVersion=m_PluginInfo.version.BeforeLast('.'); //+v0.4.1
    sPluginVersion.Replace(_T("."),_T(""));
    m_sKeyFilename = m_sKeyFilename<<wxFILE_SEP_PATH<<m_PluginInfo.name<<sPluginVersion
        <<_T("v")<<SDKverStr<<_T(".ini"); //+v0.4.1
has to be handled differently in win32 and unix OS's

HTH
tiwag
« Last Edit: January 12, 2006, 11:24:49 am by tiwag »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2784
Re: wxKeyBinder problems/solutions discussion
« Reply #15 on: January 12, 2006, 05:11:30 pm »

but there exists another problem, i can't save any new keyboard settings,

after applying the changes, keybinder pops up a messagebox, saying the
new keyboard layout is saved under "/home/tiwag//.codeblocks/cbKeyBinder04v16.ini"
but there is no such file existing :?

did you notice the double slashes in the directory-path   /home/tiwag//.codeblocks  ?

it seems, that this
Code
    //memorize the key file name as {%HOME%}\cbKeyBinder+{vers}.ini
    m_sKeyFilename = ConfigManager::GetConfigFolder();
    // remove the dots from version string (using first 3 chars)
    wxString sPluginVersion=m_PluginInfo.version.BeforeLast('.'); //+v0.4.1
    sPluginVersion.Replace(_T("."),_T(""));
    m_sKeyFilename = m_sKeyFilename<<wxFILE_SEP_PATH<<m_PluginInfo.name<<sPluginVersion
        <<_T("v")<<SDKverStr<<_T(".ini"); //+v0.4.1
has to be handled differently in win32 and unix OS's

HTH
tiwag

But.. But.. Isn't every thing but cbKeybinder04v16.ini handed to me by
ConfigManager::GetConfigFolder() ??

How can I change that ??

thanks
pecan

EDIT:
Oh, there's a <<wxFILE_SEP_PATH in there.
Now how did that get there?
« Last Edit: January 13, 2006, 01:12:20 am by Pecan »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2784
Re: wxKeyBinder problems/solutions discussion
« Reply #16 on: January 18, 2006, 03:55:42 am »
1/17/2006 9:54 PM

Have commited KeyBinder v0.4.11 (svn 1791)

Fixed GTK Update()/File Open crash
Fixed GTK not savings key bindings
Modified Attach/UpdateAllCmd for speed

Thanks
pecan

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2784
Re: wxKeyBinder problems/solutions discussion
« Reply #17 on: January 23, 2006, 03:07:41 pm »
I am aware that keybinder is broken with the new
"settings scheme" in svn 1838.

I'll put it back together as soon as I figure out where
all the pieces went.

thanks
pecan

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: wxKeyBinder problems/solutions discussion
« Reply #18 on: January 23, 2006, 05:22:11 pm »
I am aware that keybinder is broken with the new "settings scheme" in svn 1838.
Ah yes, I only just finished that one... :lol:

[attachment deleted by admin]
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

sethjackson

  • Guest
Re: wxKeyBinder problems/solutions discussion
« Reply #19 on: January 23, 2006, 05:57:54 pm »
I am aware that keybinder is broken with the new "settings scheme" in svn 1838.
Ah yes, I only just finished that one... :lol:

That is soooo cool.  :lol: You have me cryin' thomas.

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: wxKeyBinder problems/solutions discussion
« Reply #20 on: January 23, 2006, 11:22:14 pm »
Ah yes, I only just finished that one... :lol:

Very cool icon, but you might want to replace that "Strg" key with one that appears on more keyboard layouts. I've only ever seen Strg keys on German keyboards1. Using another key would make it more recognizable to more people, I think.
Maybe Alt?


1) According to Wikipedia that keyboard layout is used in Austria as well, but I don't see Strg on any of the other keyboard layouts they show.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2784
Re: wxKeyBinder problems/solutions discussion
« Reply #21 on: January 23, 2006, 11:25:05 pm »
Keybinder v0.4.13 1/23/2006 5:06 PM

Have commited KeyBinder v0.4.13 (svn 1844)


Fixed key updating broken by new settings scheme
Cleaned up code and comments
Added operator== to keybinder.h to avoid unnecessary
 updates and writes.

Thanks
pecan

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: wxKeyBinder problems/solutions discussion
« Reply #22 on: January 23, 2006, 11:38:27 pm »
Very cool icon, but you might want to replace that "Strg" key with one that appears on more keyboard layouts. I've only ever seen Strg keys on German keyboards1. Using another key would make it more recognizable to more people, I think.
Maybe Alt?
Funny, now that you mention it, I have been wondering for many years why the "control" key is not labelled "control" on PC keyboards... buf of course I haven't used an English keyboard in a decade, so I wouldn't remember :)
Macintosh calls it "control", I think.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: wxKeyBinder problems/solutions discussion
« Reply #23 on: January 24, 2006, 12:18:36 am »
Very cool icon, but you might want to replace that "Strg" key with one that appears on more keyboard layouts. I've only ever seen Strg keys on German keyboards1. Using another key would make it more recognizable to more people, I think.
Maybe Alt?
Funny, now that you mention it, I have been wondering for many years why the "control" key is not labelled "control" on PC keyboards... buf of course I haven't used an English keyboard in a decade, so I wouldn't remember :)

Heh :). Germans and their translations :P.

I've heard of such a thing as a Dutch keyboard layout, but as far as I'm concerned that's just the most annoying thing ever to happen to my Windows keyboard settings. Dead keys are evil, especially when programming in languages that use ' and " as delimiters for character/string constants :(.

Quote
Macintosh calls it "control", I think.

During the Google searches I did to investigate for that post1, I saw mac keyboards with both "Ctl" and "Ctrl". Didn't see any "Control" though. And I wouldn't know from personal experience, given that I've only used macs like two times (both > 5 years ago) in my entire life.


1) Before I noticed that Strg was Ctrl, not Shift. (I initially wanted to recommend Ctrl or Alt for use in the icon)