Howto make a button pressed callback acting as long as the button state  is down ?
- From: Jean-Max Redonnet <jmax redonnet meca insa-tlse fr>
- To: gtk-app-devel-list gnome org
- Subject: Howto make a button pressed callback acting as long as the button state  is down ?
- Date: Wed, 13 Jun 2001 08:43:23 +0200
Sorry if this has been covered before.
I have 4 buttons that makes my model rotate in a drawing area
(in a gtkglarea in fact but doesn't matters).
First try :
When I press one of this buttons a single step rotation is
done. Well good job ! but I would like the rotation process
follows as long as the button is pressed.
The problem is I don't know how to make this. I have a single
event (pressed or clicked) thus a single rotation step.
Second try :
I've tried to work with GTK_WIDGET_STATE(button) but this not
works. Here the concerned code :
void
on_rotate_left_btn_pressed             (GtkButton       *button,
                                        gpointer         user_data)
{
  GtkWidget *glarea;
  scene *pscene;
  Vec3 axis;
  double angle;
  g_print("Rotate left button clicked \n");
  glarea = lookup_widget(GTK_WIDGET(button), "glarea");
  pscene = gtk_object_get_data(GTK_OBJECT(glarea), "scene");
  axis.x = 0.0;
  axis.y = -1.0;
  axis.z = 0.0;
  angle = 5.0;
  
  while(GTK_WIDGET_STATE(button) == GTK_STATE_ACTIVE ) {
    g_print("GTK_WIDGET_STATE(button) : %i \n",
GTK_WIDGET_STATE(button));
    rotate_view_XY(axis, DEG2RAD(angle), pscene);
    redraw_widget(glarea);
  }
}
void
on_rotate_left_btn_released            (GtkButton       *button,
                                        gpointer         user_data)
{
  gtk_widget_set_state(GTK_WIDGET(button), GTK_STATE_NORMAL);
}
The problem is when I press the left_btn the rotation starts but
never ends, so the on_rotate_left_btn_released callback is never called.
How to make this to work ?
Thanks for any help.
-- 
JMR
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]