strange switch behaviour



I know that switch is not particularily well suited for modern programs,
but I thought it would work rather well for my image viewer. I catch
keyboard events and then, according to the key that was pressed, execute
actions.

Now the strange thing is:


bool AppWindow::on_key_press_event(GdkEventKey * key)
{
switch( key->keyval )

.
.
.

case GDK_s:
case GDK_S:
	if( Button_Save.is_sensitive() )
		on_button_save();
	break;
.
.
.

default:
	break;
}


when Button_Save.is_sensitive() is true, the keypress is recorded once
and everything works as it should. When it is false, the keypress is
recorded twice! (note, I tried removing the upper or lowercase version
respectively already, that does not remove the double event)

debug ouput:

the image has been modified and I press S to save it:

.....
We're all set to go and we have 2 files.
OPENFILES: Looking for /home/bartek/temp/pict9121.jpg in
/home/bartek/temp/pict91212.jpg
OPENFILES: Looking for /home/bartek/temp/pict9121.jpg in
/home/bartek/temp/pict9121.jpg
Deleting temporary dirname.
We're all set to go and we have 2 files.
Deleting the allocated memory for temporary filename.
C was pressed.
S was pressed.
....

this time the image is not modified, this causes
Button_Save.is_sensitive() to return false as the modification triggers
the buttons state

......
We're all set to go and we have 2 files.
OPENFILES: Looking for /home/bartek/temp/pict9121.jpg in
/home/bartek/temp/pict91212.jpg
OPENFILES: Looking for /home/bartek/temp/pict9121.jpg in
/home/bartek/temp/pict9121.jpg
Deleting temporary dirname.
We're all set to go and we have 2 files.
Deleting the allocated memory for temporary filename.
S was pressed.
S was pressed.
.....


Any ideas?



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