|
|
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Keyboard shortcut
Keyboard shortcut [message #21572] |
Wed, 27 May 2009 18:31 |
darthspawn
Messages: 58 Registered: February 2009
|
Member |
|
|
I need to create a keyboard shortcut like "ctrl + h", that hide the menu bar.. is possible do it? and is possible hide a button and cut the window to optimize space? thanks!
|
|
|
|
Re: Keyboard shortcut [message #21611 is a reply to message #21608] |
Fri, 29 May 2009 12:06 |
darthspawn
Messages: 58 Registered: February 2009
|
Member |
|
|
I tried now to add a key accelerator to the menu' bar, but when menu is not showed is not possible call again CTRL_H for make visible the menu bar (I tried to put some breakpoint, the function is not called). The shortcut function works when the bar is visible.
[Updated on: Fri, 29 May 2009 12:11] Report message to a moderator
|
|
|
|
|
Re: Keyboard shortcut [message #21763 is a reply to message #21760] |
Thu, 04 June 2009 15:10 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Hello, Sam.
I can provide you some example.
HideMenuExample.h:
#ifndef _HideMenuExample_HideMenuExample_h
#define _HideMenuExample_HideMenuExample_h
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class HideMenuExample : public TopWindow {
public:
typedef HideMenuExample CLASSNAME;
HideMenuExample();
FrameRight<Button> btn;
MenuBar menu;
// Bars
void MainBar(Bar& bar);
void FileBar(Bar& bar);
// GUI Events
void OnHideMenu();
void OnHideButton();
void OnButtonClick();
// Input Events
virtual bool Key(dword key, int count);
// Methods
String ShowButtonLabel(bool show) { if (show) return "Hide button"; else return "Show button"; }
};
#endif
HideMenuExample.cpp:
#include "HideMenuExample.h"
HideMenuExample::HideMenuExample()
{
Title("Hide menu example");
MaximizeBox().MinimizeBox().Sizeable().CenterScreen();
btn.SetLabel("?");
btn.WhenPush = THISBACK(OnButtonClick);
AddFrame(menu);
//AddFrame(TopSeparatorFrame());
menu.Set(THISBACK(MainBar));
menu.AddFrame(btn);
SetRect(0, 0, 640, 480);
}
void HideMenuExample::MainBar(Bar& bar)
{
bar.Add("File", THISBACK(FileBar));
}
void HideMenuExample::FileBar(Bar& bar)
{
bar.Add("Hide this menu", THISBACK(OnHideMenu)).Key(K_CTRL_H);
bar.Add(ShowButtonLabel(btn.IsVisible()), THISBACK(OnHideButton)).Key(K_CTRL_B);
bar.MenuSeparator();
bar.Add("Exit", THISBACK(Close)).Key(K_CTRL_Q);
}
void HideMenuExample::OnHideMenu()
{
menu.Show(!menu.IsVisible());
}
void HideMenuExample::OnHideButton()
{
btn.Show(!btn.IsVisible());
}
void HideMenuExample::OnButtonClick()
{
PromptOK("Clicked");
}
bool HideMenuExample::Key(dword key, int count)
{
if (!menu.IsVisible())
{
if (key == K_CTRL_H)
{
OnHideMenu();
return true;
}
else if (key == K_CTRL_Q)
{
Close();
//return true;
}
}
return TopWindow::Key(key, count);
}
GUI_APP_MAIN
{
HideMenuExample().Run();
}
[Updated on: Thu, 04 June 2009 15:54] Report message to a moderator
|
|
|
|
Re: Keyboard shortcut [message #21838 is a reply to message #21771] |
Mon, 08 June 2009 03:26 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
darthspawn wrote on Thu, 04 June 2009 17:35 | Thank you very much! your example it was greatly appreciate!
Another little question: is possible to hide the blue bar?
it's not a great problem if I can't. I've searched some information about "SetSkin()", it's that the way?
Thank you again!
Sam
|
This is another question and should be placed in appropriate topic.
Anyway, if I understood you correctly, yes it's possible to hide the main title bar of the window. For this purpose, e.g. in the Windows operating system, you can change Window Style to not include WS_CAPTION. In U++ we use TopWindow class. It have SyncCaption0 method that changes window styles. FrameLess method can be placed in window constructor. In my opinion, it is not very flexible, because you don't have system menu in this mode and must implement own areas for window placement, close, maximize, minimize buttons, etc.
SetSkin method changes how U++ widget(s) (inherited from Ctrl) looks.
[Updated on: Mon, 08 June 2009 04:10] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Apr 26 21:18:27 CEST 2024
Total time taken to generate the page: 0.03159 seconds
|
|
|