18 lines
7.1 KiB
Text
18 lines
7.1 KiB
Text
version=pmwiki-1.0.5
|
|
newline=²
|
|
text=This mimicks Windows menu activation using the ALT+key combination and then a simple keypress for the sub-menu.²Note the use of 'activate_item' instead of 'activate' which enables the menu to close on keypress.²[[include:Main/CodeTable]]²<?php²if( !extension_loaded('gtk')) { ² dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); ²}²//test functions²function func1(){² $label = &new GtkLabel( 'Go selected');² $label->show();² $GLOBALS['vbox']->add($label);²}²function func2(){² $label = &new GtkLabel( 'Clear selected');² $label->show();² $GLOBALS['vbox']->add($label);²}²//simple menu items²$menu_info = array(² '_Test'=>array(² '_Go'=>'func1',² '_Clear'=>'func2',² 'seperator'=>'',² 'E_xit'=>array('gtk','main_quit'),² )²);²²$window = &new GtkWindow();²$window->set_default_size(350, 450);²$window->connect_object('destroy', array('gtk', 'main_quit'));²//create accegroup for main window²$accelgroup =& new GtkAccelGroup();²$window->add_accel_group($accelgroup);²²//add vbox²$vbox =& new GtkVBox(FALSE, 0);²$vbox->show();²$vbox->set_spacing(1);²$window->add($vbox);²²$menubar =& new GtkMenuBar();²$menubar->set_shadow_type(GTK_SHADOW_ETCHED_IN);²//make menu²foreach($menu_info as $title=>$items){² $menu =& new GtkMenuItem($title);² $mlabel = $menu->child;² $mlabel_key = $mlabel->parse_uline($title);² if($mlabel_key){² //add accel with Alt key² $menu->add_accelerator('activate_item', $accelgroup, $mlabel_key,GDK_MOD1_MASK, 0);² $menu->lock_accelerators();² }² $menubar->append($menu);² $menu->show();² $submenu =& new GtkMenu();² //create a new accelgroup for submenus² $accel = $submenu->ensure_uline_accel_group();² foreach($items as $sub_title=>$function){² if($sub_title == 'seperator'){ ² $item =& new GtkMenuItem();² $item->set_sensitive(false);² }else{² $item =& new GtkMenuItem($sub_title);² $label = $item->child;² $label_key = $label->parse_uline($sub_title);² if(!empty($function)){² $item->connect_object('activate',$function);² if($label_key){² $item->add_accelerator('activate_item', $accel, $label_key, 0, 0);² $item->lock_accelerators();² }² }² }² $submenu->append($item);² $item->show();² }² $menu->set_submenu($submenu);²}²$menubar->show();²$vbox->pack_start($menubar,FALSE,FALSE,0);²²$window->show_all();²gtk::main();²²?>²[[include:Main/CodeTableEnd]]
|
|
time=1117377493
|
|
diff:1115650910:1115650910:=1,87c1²< This mimicks Windows menu activation using the ALT+key combination and then a simple keypress for the sub-menu.²< Note the use of 'activate_item' instead of 'activate' which enables the menu to close on keypress.²< [[include:Main/CodeTable]]²< <?php²< if( !extension_loaded('gtk')) { ²< dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); ²< }²< //test functions²< function func1(){²< $label = &new GtkLabel( 'Go selected');²< $label->show();²< $GLOBALS['vbox']->add($label);²< }²< function func2(){²< $label = &new GtkLabel( 'Clear selected');²< $label->show();²< $GLOBALS['vbox']->add($label);²< }²< //simple menu items²< $menu_info = array(²< '_Test'=>array(²< '_Go'=>'func1',²< '_Clear'=>'func2',²< 'seperator'=>'',²< 'E_xit'=>array('gtk','main_quit'),²< )²< );²< ²< $window = &new GtkWindow();²< $window->set_default_size(350, 450);²< $window->connect_object('destroy', array('gtk', 'main_quit'));²< //create accegroup for main window²< $accelgroup =& new GtkAccelGroup();²< $window->add_accel_group($accelgroup);²< ²< //add vbox²< $vbox =& new GtkVBox(FALSE, 0);²< $vbox->show();²< $vbox->set_spacing(1);²< $window->add($vbox);²< ²< $menubar =& new GtkMenuBar();²< $menubar->set_shadow_type(GTK_SHADOW_ETCHED_IN);²< //make menu²< foreach($menu_info as $title=>$items){²< $menu =& new GtkMenuItem($title);²< $mlabel = $menu->child;²< $mlabel_key = $mlabel->parse_uline($title);²< if($mlabel_key){²< //add accel with Alt key²< $menu->add_accelerator('activate_item', $accelgroup, $mlabel_key,GDK_MOD1_MASK, 0);²< $menu->lock_accelerators();²< }²< $menubar->append($menu);²< $menu->show();²< $submenu =& new GtkMenu();²< //create a new accelgroup for submenus²< $accel = $submenu->ensure_uline_accel_group();²< foreach($items as $sub_title=>$function){²< if($sub_title == 'seperator'){ ²< $item =& new GtkMenuItem();²< $item->set_sensitive(false);²< }else{²< $item =& new GtkMenuItem($sub_title);²< $label = $item->child;²< $label_key = $label->parse_uline($sub_title);²< if(!empty($function)){²< $item->connect_object('activate',$function);²< if($label_key){²< $item->add_accelerator('activate_item', $accel, $label_key, 0, 0);²< $item->lock_accelerators();²< }²< }²< }²< $submenu->append($item);²< $item->show();²< }²< $menu->set_submenu($submenu);²< }²< $menubar->show();²< $vbox->pack_start($menubar,FALSE,FALSE,0);²< ²< $window->show_all();²< gtk::main();²< ²< ?>²< [[include:Main/CodeTableEnd]]²\ No newline at end of file²---²> Describe ActivateMenuBarWithALTKey here.²\ No newline at end of file²
|
|
author=Scott
|
|
author:1115650910=Tom Rogers
|
|
host:1115650910=203.20.132.4
|
|
name=CodeHints.ActivateMenuBarWithALTKey
|
|
host=68.199.17.225
|
|
agent=Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2
|
|
rev=3
|
|
diff:1117219185:1115650910:=87,101c87²< [[include:Main/CodeTableEnd]]²< ²< ==Links==²< ²< [[http://valium1.dezigner.ru/ valium]]²< [[http://vicodin-buy.bigsitecity.com/ buy vicodin online]]²< [[http://fioricet-online1.bigsitecity.com/ buy fioricet]]²< [[http://steroids1.bigsitecity.com/ buy hydrocodone]]²< [[http://hydrocodone1.bigsitecity.com/ anabolic steroid]]²< [[http://phentermine1.bigsitecity.com/ purchase phentermine]]²< [[http://phentermine-online1.bigsitecity.com/ buy phentermine online]]²< [[http://buy-phentermine1.bigsitecity.com/ cheapest phentermine cod]]²< [[http://cheap-phentermine1.bigsitecity.com/ phentermine pharmacy]]²< [[http://cheap-phentermine-online1.bigsitecity.com/ buy cheap phentermine]]²< [[http://buy-phentermine-online2.bigsitecity.com/ phentermine online pharmacy]]²\ No newline at end of file²---²> [[include:Main/CodeTableEnd]]²\ No newline at end of file²
|
|
author:1117219185=t
|
|
host:1117219185=62.33.112.3
|
|
diff:1117377493:1117219185:=87c87,101²< [[include:Main/CodeTableEnd]]²\ No newline at end of file²---²> [[include:Main/CodeTableEnd]]²> ²> ==Links==²> ²> [[http://valium1.dezigner.ru/ valium]]²> [[http://vicodin-buy.bigsitecity.com/ buy vicodin online]]²> [[http://fioricet-online1.bigsitecity.com/ buy fioricet]]²> [[http://steroids1.bigsitecity.com/ buy hydrocodone]]²> [[http://hydrocodone1.bigsitecity.com/ anabolic steroid]]²> [[http://phentermine1.bigsitecity.com/ purchase phentermine]]²> [[http://phentermine-online1.bigsitecity.com/ buy phentermine online]]²> [[http://buy-phentermine1.bigsitecity.com/ cheapest phentermine cod]]²> [[http://cheap-phentermine1.bigsitecity.com/ phentermine pharmacy]]²> [[http://cheap-phentermine-online1.bigsitecity.com/ buy cheap phentermine]]²> [[http://buy-phentermine-online2.bigsitecity.com/ phentermine online pharmacy]]²\ No newline at end of file²
|
|
author:1117377493=Scott
|
|
host:1117377493=68.199.17.225
|