feat: add click-outside-to-close for picker dialogs

resolve #226
This commit is contained in:
Richard Radics 2025-02-05 22:44:03 +01:00
parent d348ac66de
commit 86324c2a24
6 changed files with 45 additions and 0 deletions

View file

@ -44,6 +44,15 @@ CLASS_DECLARATION(USignal, FilePickerClass, NULL) {
FilePickerClass::FilePickerClass()
{
overlay = new UIButton();
overlay->InitFrame(NULL,
UIRect2D(0, 0, uid.vidWidth, uid.vidHeight),
0);
overlay->setBackgroundColor(UColor(0, 0, 0, 0), true);
overlay->AllowActivate(true);
overlay->Connect(this, W_Button_Pressed, W_Deactivated);
overlay->AddFlag(WF_ALWAYS_BOTTOM);
window = new UIFloatingWindow();
window->Create(
NULL,
@ -72,6 +81,11 @@ FilePickerClass::FilePickerClass()
FilePickerClass::~FilePickerClass()
{
if (overlay) {
delete overlay;
overlay = NULL;
}
if (listbox) {
delete listbox;
listbox = NULL;

View file

@ -26,6 +26,7 @@ class UIListCtrl;
class FilePickerClass : public USignal
{
UIButton *overlay;
UIFloatingWindow *window;
UIListCtrl *listbox;
str currentDirectory;

View file

@ -48,6 +48,15 @@ CLASS_DECLARATION(USignal, MpMapPickerClass, NULL) {
MpMapPickerClass::MpMapPickerClass()
{
overlay = new UIButton();
overlay->InitFrame(NULL,
UIRect2D(0, 0, uid.vidWidth, uid.vidHeight),
0);
overlay->setBackgroundColor(UColor(0, 0, 0, 0), true);
overlay->AllowActivate(true);
overlay->Connect(this, W_Button_Pressed, W_Deactivated);
overlay->AddFlag(WF_ALWAYS_BOTTOM);
window = new UIFloatingWindow();
window->Create(
NULL,
@ -79,6 +88,11 @@ MpMapPickerClass::MpMapPickerClass()
MpMapPickerClass::~MpMapPickerClass()
{
if (overlay) {
delete overlay;
overlay = NULL;
}
if (listbox) {
delete listbox;
listbox = NULL;

View file

@ -26,6 +26,7 @@ class UIFloatingWindow;
class MpMapPickerClass : public USignal
{
UIButton *overlay;
UIFloatingWindow *window;
UIListCtrl *listbox;
str currentDirectory;

View file

@ -152,6 +152,15 @@ CLASS_DECLARATION(USignal, PlayerModelPickerClass, NULL) {
PlayerModelPickerClass::PlayerModelPickerClass()
{
overlay = new UIButton();
overlay->InitFrame(NULL,
UIRect2D(0, 0, uid.vidWidth, uid.vidHeight),
0);
overlay->setBackgroundColor(UColor(0, 0, 0, 0), true);
overlay->AllowActivate(true);
overlay->Connect(this, W_Button_Pressed, W_Deactivated);
overlay->AddFlag(WF_ALWAYS_BOTTOM);
window = new UIFloatingWindow();
window->Create(
NULL,
@ -185,6 +194,11 @@ PlayerModelPickerClass::PlayerModelPickerClass()
PlayerModelPickerClass::~PlayerModelPickerClass()
{
if (overlay) {
delete overlay;
overlay = NULL;
}
if (listbox) {
delete listbox;
listbox = NULL;

View file

@ -26,6 +26,7 @@ class UIFloatingWindow;
class PlayerModelPickerClass : public USignal
{
UIButton *overlay;
UIFloatingWindow *window;
UIListCtrl *listbox;
str currentDirectory;