strange behaviour with touch-panel
- From: "Lukasz Gromotowicz" <gromot gmail com>
- To: gkt+ <gtk-list gnome org>
- Subject: strange behaviour with touch-panel
- Date: Fri, 12 Sep 2008 11:07:18 +0100
Hi all,
is there anything I should add in my GTK application to use a touch-panel instead of mouse?
The problem I have is that very often when the mouse pointer is over button1 and I press on button2 I receive events "pressed" and "released" for button1. There is no "clicked" event at all, and there is no events for the actually pressed button.
When we use a traditional mouse, we first move the pointer then click --> there is no problems with that. But using a touch panel it looks like sometimes the "pressed" signal was sent and after that the mouse pointer moved to the pressed position.
I wrote a simple test application with two buttons. When I click on the buttons alternatively, I can see that the problem occurs for about 20% of clicks.
Best regards,
LUK
P.S. If anybody is interested in, below is the whole program I wrote. It uses a .glade file which contains 2 buttons and a TextView.
#include <gtk/gtk.h>
#include <libglade-2.0/glade/glade.h>
void onButtonClicked(GtkWidget *widget, gpointer user_data);
void onButtonPressed(GtkWidget *button, gpointer user_data);
void onButtonReleased(GtkWidget *button, gpointer user_data);
void addLine(char* line, GtkTextTag *tag);
GtkWidget *b1, *b2, *tv;
GtkTextTag *tag1, *tag2;
int main (int argc, char *argv[])
{
gtk_init(&argc, &argv);
// create the form (load from the xml file)
GladeXML* glade_xml = glade_xml_new("window.glade",NULL,NULL);
// assign pointers to widgets
b1 = glade_xml_get_widget(glade_xml,"b1");
b2 = glade_xml_get_widget(glade_xml,"b2");
tv = glade_xml_get_widget(glade_xml,"textview1");
// connect signals to the widgets
g_signal_connect(b1, "clicked", (GCallback)onButtonClicked, NULL);
g_signal_connect(b2, "clicked", (GCallback)onButtonClicked, NULL);
g_signal_connect(b1, "pressed", (GCallback)onButtonPressed, NULL);
g_signal_connect(b2, "pressed", (GCallback)onButtonPressed, NULL);
g_signal_connect(b1, "released", (GCallback)onButtonReleased, NULL);
g_signal_connect(b2, "released", (GCallback)onButtonReleased, NULL);
g_object_unref(glade_xml);
GtkTextBuffer *tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tv));
tag1 = gtk_text_buffer_create_tag (tb, NULL, "foreground", "darkBlue", NULL);
tag2 = gtk_text_buffer_create_tag (tb, NULL, "foreground", "green", NULL);
gtk_main();
}
void addLine(char* line, GtkTextTag *tag)
{
GtkTextIter startIter, endIter;
GtkTextBuffer *tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tv));
gtk_text_buffer_get_end_iter(tb, &startIter);
gint startOffset = gtk_text_iter_get_offset(&startIter);
gtk_text_buffer_insert(tb, &startIter, line, -1);
gtk_text_buffer_get_end_iter(tb, &endIter);
gtk_text_buffer_get_iter_at_offset(tb, &startIter, startOffset);
if (tag != NULL)
gtk_text_buffer_apply_tag (tb, tag, &startIter, &endIter);
g_signal_emit_by_name(tv, "move-viewport", GTK_SCROLL_ENDS, 2, NULL, NULL);
}
void onButtonClicked(GtkWidget *widget, gpointer user_data)
{
if (widget == b1) addLine("1: clicked\n", tag1);
else addLine("2: clicked\n", tag2);
}
void onButtonPressed(GtkWidget *button, gpointer user_data)
{
if (button == b1) addLine("1: pressed\n", tag1);
else addLine("2: pressed\n", tag2);
}
void onButtonReleased(GtkWidget *button, gpointer user_data)
{
if (button == b1) addLine("1: released\n", tag1);
else addLine("2: released\n", tag2);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]