PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
GtkNotebook Ctrl+Tab Switching Problem (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: GtkNotebook Ctrl+Tab Switching Problem
#185
cesutherland (User)
Fresh Boarder
Posts: 8
graphgraph
User Offline Click here to see the profile of this user
GtkNotebook Ctrl+Tab Switching Problem 2 Months, 3 Weeks ago Karma: 0  
I am working on a preferences dialog that makes use of a GtkNotebook for organizing categories of preferences.

It would make sense for usability if I could allow users to switch between tabs with the common Ctrl+Tab sequence, and I have actually gotten this to work.

    The problem is:
after switching the active tab, the Tab key then also selects the next widget within the dialog. How can I prevent this from happening? How can I disable the Tab to next widget.

-Carl

Connection:
Code:
$this->notebook->connect('key_press_event', array($this, nextTab));
Callback:
Code:
function nextTab($widget, $event)
{
	if ($event->state == Gdk::CONTROL_MASK && $event->keyval == Gdk::KEY_Tab) {
		if ($widget->get_current_page() == $widget->get_n_pages()-1) {
			$widget->set_current_page(0);
		} else {
			$widget->next_page();
		}
	}
}
 
  The administrator has disabled public write access.
#186
wim stockman (User)
Fresh Boarder
Posts: 19
graphgraph
User Offline Click here to see the profile of this user
Re:GtkNotebook Ctrl+Tab Switching Problem 2 Months, 3 Weeks ago Karma: 0  
Maybe you could try to set the focus on the element you want.
 
  The administrator has disabled public write access.
#187
cesutherland (User)
Fresh Boarder
Posts: 8
graphgraph
User Offline Click here to see the profile of this user
Re:GtkNotebook Ctrl+Tab Switching Problem 2 Months, 3 Weeks ago Karma: 0  
Thanks. Really simple! $this is the preferences class -- an extension of GtkDialog. set_focus_child to the notebook works.

Solution:

Code:
function nextTab($notebook,$event)
{
	if ($event->state == Gdk::CONTROL_MASK && $event->keyval == Gdk::KEY_Tab) {
		if ($notebook->get_current_page() == $notebook->get_n_pages()-1) {
			$notebook->set_current_page(0);
		} else {
			$notebook->next_page();
		}
		$this->set_focus_child($notebook);
	}
	
}
 
 
Last Edit: 2008/04/29 13:04 By cesutherland.
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Copyright © 2006-2008. kksou.com. All Rights Reserved