solution (good enough for now) -> Re: how to get rid of mouse-over button color?

On Sun, May 01, 2005 at 04:48:20PM -0700, Ben Johnson wrote:
> Hi.
> I'm working with a touch screen, which I'm learning makes mouse-over
> types of events sort of meaningless.  Yet, they still occur.
> I have a page full of toggle buttons and it can be difficult to
> determine when one is down.  The easiest way to tell is by looking at
> the button's color.  The problem is, if I push a button with the touch
> screen the mouse doesn't move out of the button when I move my pointer
> (finger) away from the button.  The result is, the color doesn't change
> and it's hard to if my intended action succeeded.
> I want the mouse-over color to go away so that I just have a "normal"
> and an "active" color for the buttons.  Is there an easy way to do this?
> I'm thinking about programmatically moving the mouse pointer to some
> neutral location after each toggle button selection.  (don't know how to
> do that (yet).)  Is there another way?

I have a found a quick and dirty way to disable the prelight
(mouse-over) color where it causes me the most trouble.  I connect the
following signal handler to the "state-changed" GtkWidget signal.  All
it does it check to see what color the toggle button should be set to
(based on my appliction specific heuristics) and then uses that color to
set the GTK_STATE_PRELIGHT bg and fg widget color states.  it's oh so
simple and introduces no descernable delay.  I'm choosing to use this
method because themes appear to not be flexible or manageable enough for
my needs in this case.

Thanks for the help.

- Ben

static void
on_menuitem_toggle_state_changed           (GtkWidget *widget,
                                            GtkStateType state,
                                            gpointer user_data)
    GtkStateType   betterstate = GTK_STATE_NORMAL;
    GtkStyle     * style       = NULL;

#if 0
    if( state != GTK_STATE_PRELIGHT )

    g_return_if_fail( GTK_IS_TOGGLE_BUTTON(widget) );

    if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) )
        betterstate = GTK_STATE_ACTIVE;
        betterstate = GTK_STATE_NORMAL;

    style = gtk_widget_get_style (widget);

    if(   style->bg[ GTK_STATE_PRELIGHT ].red   != style->bg[ betterstate ].red
       || style->bg[ GTK_STATE_PRELIGHT ].green != style->bg[ betterstate ].green
       || style->bg[ GTK_STATE_PRELIGHT ].blue  != style->bg[ betterstate ].blue
        gtk_widget_modify_bg( widget, GTK_STATE_PRELIGHT, &(style->bg[ betterstate ]) );
        gtk_widget_modify_fg( widget, GTK_STATE_PRELIGHT, &(style->fg[ betterstate ]) );

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]