YOu can now activate the menu pressing F10 anywhere.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2511 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-05-19 13:41:55 +00:00
parent 3dfb93fd82
commit 801aa1782c
6 changed files with 68 additions and 6 deletions

View File

@@ -95,8 +95,6 @@ public:
GtkAccelGroup *m_accel;
GtkItemFactory *m_factory;
private:
wxList m_menus;
GtkWidget *m_menubar;
};

View File

@@ -95,8 +95,6 @@ public:
GtkAccelGroup *m_accel;
GtkItemFactory *m_factory;
private:
wxList m_menus;
GtkWidget *m_menubar;
};

View File

@@ -24,6 +24,7 @@
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h"
#include "gdk/gdkkeysyms.h"
//-----------------------------------------------------------------------------
// constants
@@ -132,7 +133,8 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
static void gtk_toolbar_detached_callback( GtkWidget *widget, GtkWidget *WXUNUSED(child), wxFrame *win )
{
if (g_isIdle) wxapp_install_idle_handler();
if (g_isIdle)
wxapp_install_idle_handler();
if (!win->m_hasVMT) return;

View File

@@ -630,6 +630,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
ret = win->GetEventHandler()->ProcessEvent( new_event );
}
/* generate wxID_CANCEL if <esc> has been pressed (typically in dialogs) */
if ( (!ret) &&
(gdk_event->keyval == GDK_Escape) )
{
@@ -638,6 +639,36 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
ret = win->GetEventHandler()->ProcessEvent( new_event );
}
/* pressing F10 will activate the menu bar of the top frame */
if ( (!ret) &&
(gdk_event->keyval == GDK_F10) )
{
wxWindow *ancestor = win;
while (ancestor)
{
if (wxIsKindOf(ancestor,wxFrame))
{
wxFrame *frame = (wxFrame*) ancestor;
wxMenuBar *menubar = frame->GetMenuBar();
if (menubar)
{
wxNode *node = menubar->GetMenus().First();
if (node)
{
wxMenu *firstMenu = (wxMenu*) node->Data();
gtk_menu_shell_select_item(
GTK_MENU_SHELL(menubar->m_menubar),
firstMenu->m_owner );
ret = TRUE;
break;
}
}
}
ancestor = ancestor->GetParent();
}
}
/*
Damn, I forgot why this didn't work, but it didn't work.

View File

@@ -24,6 +24,7 @@
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h"
#include "gdk/gdkkeysyms.h"
//-----------------------------------------------------------------------------
// constants
@@ -132,7 +133,8 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
static void gtk_toolbar_detached_callback( GtkWidget *widget, GtkWidget *WXUNUSED(child), wxFrame *win )
{
if (g_isIdle) wxapp_install_idle_handler();
if (g_isIdle)
wxapp_install_idle_handler();
if (!win->m_hasVMT) return;

View File

@@ -630,6 +630,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
ret = win->GetEventHandler()->ProcessEvent( new_event );
}
/* generate wxID_CANCEL if <esc> has been pressed (typically in dialogs) */
if ( (!ret) &&
(gdk_event->keyval == GDK_Escape) )
{
@@ -638,6 +639,36 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
ret = win->GetEventHandler()->ProcessEvent( new_event );
}
/* pressing F10 will activate the menu bar of the top frame */
if ( (!ret) &&
(gdk_event->keyval == GDK_F10) )
{
wxWindow *ancestor = win;
while (ancestor)
{
if (wxIsKindOf(ancestor,wxFrame))
{
wxFrame *frame = (wxFrame*) ancestor;
wxMenuBar *menubar = frame->GetMenuBar();
if (menubar)
{
wxNode *node = menubar->GetMenus().First();
if (node)
{
wxMenu *firstMenu = (wxMenu*) node->Data();
gtk_menu_shell_select_item(
GTK_MENU_SHELL(menubar->m_menubar),
firstMenu->m_owner );
ret = TRUE;
break;
}
}
}
ancestor = ancestor->GetParent();
}
}
/*
Damn, I forgot why this didn't work, but it didn't work.