Key Events in wxDataViewCtrl

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
Rick
Knows some wx things
Knows some wx things
Posts: 33
Joined: Fri Sep 02, 2016 12:26 pm

Key Events in wxDataViewCtrl

Post by Rick »

I found a strange behaviour: When using a wxDataViewCtrl and I hit CTRL+F then a little text bar opens which looks like a search bar. Entering text there does not filter and I didn't find anything in the API that would handle this. I don't know if it's the OS or WindowManager (I'm on Debian9 Gnome).

Now the strange part: I cannot catch any EVT_KEY or CHAR(_HOOK) events with that control. They're only caught when I've clicked on a column before. That is, when I click in the table part then any keyboard input opens the said search bar.

Can anyone tell me what this text field is or how I can stop it from appearing in order to implement my own search text field?


This does not happen with a wxDataViewListCtrl. When subclassing that I could catch the events normally and react to them.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Key Events in wxDataViewCtrl

Post by doublemax »

I don't think the search bar comes from wxWidgets, i guess it's a feature of the underlying native control.
I cannot catch any EVT_KEY or CHAR(_HOOK) events with that control.
How did you bind them? Can you try a wxAcceleratorTable?
This does not happen with a wxDataViewListCtrl. When subclassing that I could catch the events normally and react to them.
This is a big mistery to me, as wxDataViewListCtrl only wraps a different API around wxDataViewCtrl . This shouldn't have any effect on key event handling.
Use the source, Luke!
Rick
Knows some wx things
Knows some wx things
Posts: 33
Joined: Fri Sep 02, 2016 12:26 pm

Re: Key Events in wxDataViewCtrl

Post by Rick »

I bound the event listener statically and dynamically, same result.
I didn't know about the wxAcceleratorTable. I used it but the "default" text field still opens.
What event does it produce though? wxEVT_MENU?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Key Events in wxDataViewCtrl

Post by doublemax »

I bound the event listener statically and dynamically, same result.
Did you Bind it to the control itself (which you must do) or the frame (which won't work)?
I didn't know about the wxAcceleratorTable. I used it but the "default" text field still opens.
What event does it produce though? wxEVT_MENU?
Yes.
Use the source, Luke!
Rick
Knows some wx things
Knows some wx things
Posts: 33
Joined: Fri Sep 02, 2016 12:26 pm

Re: Key Events in wxDataViewCtrl

Post by Rick »

I bound the control itself. In the constructor since I'm subclassing the wxDataViewCtrl.
I used a static EVT_MENU binding to check if the event raised by the wxAcceleratorTable are processed. The handler function was not called.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Key Events in wxDataViewCtrl

Post by doublemax »

Sorry, then i'm out of ideas. And as i work exclusively under Windows, i can't test this myself.

BTW: Does the search bar also appear in the "dataview" sample that comes with wxWidgets?
Use the source, Luke!
Rick
Knows some wx things
Knows some wx things
Posts: 33
Joined: Fri Sep 02, 2016 12:26 pm

Re: Key Events in wxDataViewCtrl

Post by Rick »

The exact same behaviour also occurs in the sample. Also that this search bar does not appear in the wxDataViewListCtrl/TreeCtrl.

I've searched the web a little and also tested it in other native linux applications (such as rhythmbox). Same behaviour except for that rhythmbox handles the ctrl+f combination.

Now, it seems to be a GTK "feature". Which can be disabled in code:

According to some posts

Code: Select all

gboolean gtk_tree_view_get_disable_search (GtkTreeView *tree_view); 
disables the search bar when the user starts typing

and

Code: Select all

void gtk_tree_view_set_search_column (GtkTreeView *tree_view, gint column);
with column=-1 disables the entire search (and thus the ctrl+f)

https://developer.gnome.org/gtk3/stable ... rch-column

I thought about doing something like this:

Code: Select all

gtk_tree_view_get_disable_search(GTK_TREE_VIEW(GtkGetTreeView()));
gtk_tree_view_set_search_column(GTK_TREE_VIEW(GtkGetTreeView()),-1);
but the functions are unkown unless I include <gtk-3.0/gtk/gtk.h>
(compiler flags: `pkg-config --cflags gtk+-3.0` linker flags:`pkg-config --libs gtk+-3.0`)
But then my programme doesn't compile anymore (among other erroes like this):
In file included from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:30:0,
from /usr/include/gtk-3.0/gdk/gdk.h:32,
from /usr/include/gtk-3.0/gtk/gtk.h:30,
from /home/Foo/Netbeans/C++/List/DataView.cpp:13:
/usr/include/gtk-3.0/gdk/gdktypes.h:93:39: error: conflicting declaration ‘typedef cairo_rectangle_int_t GdkRectangle’
I guess it's because of circular inclusion or something? wxWidgets includes or defines some GTK stuff somewhere I suppose. Is it possible to use both together so I can use GTK functions?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Key Events in wxDataViewCtrl

Post by doublemax »

but the functions are unkown unless I include <gtk-3.0/gtk/gtk.h>
Are you actually using GTK3? The default for wxWidgets is GTK2. In any case, it's important that you use the exact same header files that were used for building wxWidgets itself.

The GTK implementation of wxDVC includes these files:

Code: Select all

#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/event.h"
#include "wx/gtk/private/gdkconv.h"
#include "wx/gtk/private/gtk2-compat.h"
#include "wx/gtk/private/list.h"
Try adding them one by one (after any other wx header, but before any third party headers.
Use the source, Luke!
Rick
Knows some wx things
Knows some wx things
Posts: 33
Joined: Fri Sep 02, 2016 12:26 pm

Re: Key Events in wxDataViewCtrl

Post by Rick »

I upgraded to Debian 10, installed the gtk3-dev package again and it worked. The search bar still appears though. But now the wxAcceleratorTable works and I just used another key combination (ctrl+f is still swallowed). That's good enough for now.
Post Reply