Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Toolbar clears after ESC key [solved, it`s the bug in user code]
Toolbar clears after ESC key [solved, it`s the bug in user code] [message #12082] |
Wed, 10 October 2007 18:33 |
Mindtraveller
Messages: 917 Registered: August 2007 Location: Russia, Moscow rgn.
|
Experienced Contributor |
|
|
I have a toolbar on my topwindow and a simple test routine for adding icons for toolbar:
class MainWindow : public WithMainWindowLayout<TopWindow> {
public:
typedef MainWindow CLASSNAME;
MainWindow();
private:
void SetToolBarState();
void OnUpdateToolbar(Bar &bar);
void OnLockUnlock();
[COLOR=blue]ToolBar toolbar;[/COLOR]
ToolBarState toolbarState;
bool buttonClose;
};
MainWindow::MainWindow()
{
::CtrlLayout(*this);
AddFrame(toolbar);
toolbar.AddFrame(BottomSeparatorFrame());
Title(t_("Диспетчер готовой продукции 0.1"));
Icon(DispRVPFImages::DISP_RVPF);
LargeIcon(DispRVPFImages::DISP_RVPF);
//Zoomable().Sizeable().
MinimizeBox(false).Sizeable(false).SetRect(0,0,1024,768);
[COLOR=blue]SetToolBarState();[/COLOR]
}
void MainWindow::SetToolBarState()
{
//...
toolbar.Set(THISBACK(OnUpdateToolbar));
}
void MainWindow::OnUpdateToolbar(Bar &bar)
{
toolbar.Clear();
toolbar.Add(t_("*********"), DispRVPFImages::dailyReport,THISBACK(OnLockUnlock));
toolbar.GapRight();
toolbar.Add(t_("*********"), DispRVPFImages::unlock,THISBACK(OnLockUnlock));
toolbar.Separator();
toolbar.Add(t_("*********"), DispRVPFImages::report,THISBACK(OnLockUnlock));
toolbar.Add(t_("*********"), DispRVPFImages::archive,THISBACK(OnLockUnlock));
toolbar.Add(t_("*********"), DispRVPFImages::options,THISBACK(OnLockUnlock));
}
It works fine on executing the application. But pressing ESC key clears toolbar icons. Is it a bug, or I`m doing something wrong?
I tried not to use toolbar.Clear(); in MainWindow::OnUpdateToolbar, but in some repainting cases toolbar just copies it`s icons twice or more times.
[Updated on: Wed, 10 October 2007 21:53] Report message to a moderator
|
|
|
Re: Toolbar clears after ESC key [bug?] [message #12084 is a reply to message #12082] |
Wed, 10 October 2007 19:03 |
Oblivion
Messages: 1094 Registered: August 2007
|
Senior Contributor |
|
|
Quote: | ; in MainWindow::OnUpdateToolbar, but in some repainting cases toolbar just copies it`s icons twice or more times.
|
Hmm, do you use a key hook (InstallKeyHook())? I've encountered the very same problem, and it was only because of the wrong return value. If you use a global keyhook, make sure that it returns true. and before it, make sure that your callback passes the variables to the default ctrl. Eg.
static bool CtrlKeyHook(Ctrl* ctrl, dword key, int count) { /* your code goes here... */ ctrl->Key(key, count); return true; }
As in the above snippet.
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Wed, 10 October 2007 19:06] Report message to a moderator
|
|
|
|
Re: Toolbar clears after ESC key [bug?] [message #12089 is a reply to message #12085] |
Wed, 10 October 2007 20:21 |
Oblivion
Messages: 1094 Registered: August 2007
|
Senior Contributor |
|
|
I've compiled your code (with small modifications, and got the same result, strange...). But i didn't have to examine the actual process that caused trouble
Fortunately, if you use OnUpdateToolbar solely for adding adding the toolbar for once and refreshing it afterwards, this should work (a temporary/application specific solution):
void MainWindow::OnUpdateToolbar(Bar &bar)
{
if(toolbar.IsOpen() && toolbar.IsChild())
{
Refresh();
return;
}
toolbar.Add(t_("*********"), DispRVPFImages::dailyReport,THISBACK(OnLockUnlock));
toolbar.GapRight();
toolbar.Add(t_("*********"), DispRVPFImages::unlock,THISBACK(OnLockUnlock));
toolbar.Separator();
toolbar.Add(t_("*********"), DispRVPFImages::report,THISBACK(OnLockUnlock));
toolbar.Add(t_("*********"), DispRVPFImages::archive,THISBACK(OnLockUnlock));
toolbar.Add(t_("*********"), DispRVPFImages::options,THISBACK(OnLockUnlock));
}
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Wed, 10 October 2007 20:31] Report message to a moderator
|
|
|
|
Re: Toolbar clears after ESC key [bug?] [message #12094 is a reply to message #12091] |
Wed, 10 October 2007 21:06 |
Oblivion
Messages: 1094 Registered: August 2007
|
Senior Contributor |
|
|
Oops sorry, it was my fault.
It seems that you are adding the items to the wrong place.
Since you use toolbar.Set() to add your items to the toolbar, You should add the items to the "bar." Not explicitly to the toolbar.
Since OnUpdateToolbar is a callback, the argument passed as "bar" is implicitly the toolbar itself. That's why your code doubles the items whenever it refreshes.
void MainWindow::OnUpdateToolbar(Bar &bar)
{
bar.Add(t_("*********"), DispRVPFImages::dailyReport,THISBACK(OnLockUnlock));
bar.GapRight();
bar.Add(t_("*********"), DispRVPFImages::unlock,THISBACK(OnLockUnlock));
bar.Separator();
bar.Add(t_("*********"), DispRVPFImages::report,THISBACK(OnLockUnlock));
bar.Add(t_("*********"), DispRVPFImages::archive,THISBACK(OnLockUnlock));
bar.Add(t_("*********"), DispRVPFImages::options,THISBACK(OnLockUnlock));
}
Now you should be able to use it as you intended.
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Wed, 10 October 2007 21:22] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Wed May 15 04:14:38 CEST 2024
Total time taken to generate the page: 0.02234 seconds
|