RE: Text Entry and GdkCrossingEvents
- From: "Aaron Geier" <ageier catalystmicro com>
- To: "Jonathon Jongsma" <jonathon jongsma gmail com>
- Cc: gtkmm-list gnome org
- Subject: RE: Text Entry and GdkCrossingEvents
- Date: Tue, 28 Aug 2007 13:49:00 -0600
Hello,
The following is a test program that should compile (I apologize if it
doesn't compile; I had to do a re-type of the program):
#include <iostream>
#include <gtkmm.h>
Class LevelEntry : public Gtk::Entry
{
public:
LevelEntry();
~LevelEntry();
protected:
bool on_enter_notify_event(GdkEventCrossing *event);
};
LevelEntry::LevelEntry()
{
set_max_length(3);
set_width_chars(4);
set_text("");
set_events(Gdk::ENTER_NOTIFY_MASK);
}
bool LevelEntry::on_enter_notify_event(GdkEventCrossing *event)
{
static long count;
if(event->type == GDK_ENTER_NOTIFY)
cerr << "Enter " << count << endl;
count++;
return true;
}
LevelEntry::~LevelEntry()
{
}
Class MyWindow : public Gtk::Window
{
public:
MyWindow();
virutal ~MyWindow();
LevelEntry m_LevelEntry;
Gtk::Vbox m_VBox;
Gtk::ScrolledWindow m_ScrolledWindow;
};
MyWindow::MyWindow()
{
set_title("Test");
set_default_size(1024,768);
resize(1024,768);
set_border_width(5);
set_decorated(false);
add(m_VBox);
m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC,
GTK::POLICY_AUTOMATIC);
m_VBox.pack_start(m_ScrolledWindow);
m_VBox.pack_start(m_LevelEntry);
show_all_children();
}
MyWindow::~MyWindow()
{
}
int main(int argc, char *argv[])
{
Gtk::Main kit(argc,argv);
MyWindow main_window;
Gtk::Main::run(main_window);
return(0);
}
}
-----Original Message-----
From: Jonathon Jongsma [mailto:jonathon jongsma gmail com]
Sent: Tuesday, August 28, 2007 12:01 PM
To: Aaron Geier
Cc: gtkmm-list gnome org
Subject: Re: Text Entry and GdkCrossingEvents
On 8/28/07, Aaron Geier <ageier catalystmicro com> wrote:
> Hello,
>
> I've created a custom class that uses the Gtk::Entry widget.
>
> In this custom class, I've overridden the on_enter_notify event. I
have
> used the set_events() command in the constructor using only the Gdk
entry
> notify mask as a parameter.
>
> A problem that I'm having is that this event call back is getting
called
> multiple times when I cross my mouse over the widget, even though I
only
> enter the widget once. For what I'm trying to do, this should only
happen
> once when I enter the widget.
>
> I've noticed two things:
>
> 1) I've tried using the set_has_frame(true) [which is the
default],
> and the event callback is called when my mouse touches the frame, and
then
> again when my mouse goes over the "text box" and my cursor changes
from a
> pointer to a "text-edit" cursor. The event callback is called a total
of
> two times.
>
> 2) I've tried using the set_has_frame(false), and the event
callback
> is called 3 times. As soon as my mouse touches the widget, it
immediately
> is changed to the "text-edit" cursor, and the callback is called 3
times.
>
> Does anyone know why this callback is being called multiple times,
even
> though the mouse only enters the widget once?
Maybe somebody else will have ideas just from your description above,
but for me it would help to have a minimal compilable test case that I
can look at and see what you're talking about.
--
jonner
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]