I Guess it's a real problem with UAK in terms of some widgets, Ultra Engine should be tested on Linux distros X11/Wayland on most popular window managers like i3 bspwm and on GNOME/KDE/XFCE and others.
If i find problems like that, i am going to report that in the future.
for now i created poor version of custom menu
#include "UltraEngine.h"
using namespace UltraEngine;
//Declare new style constants
enum CustomMenuStyle
{
CUSTOM_MENU_DEFAULT = 0
};
//Declare new widget class
class CustomMenuWidget : public Widget
{
//Custom members
bool hover;
shared_ptr<Panel> contextMenu;
shared_ptr<Widget> editButton;
shared_ptr<Widget> removeButton;
protected:
virtual bool Initialize(const WString& text, const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, const int style)
{
bool isInit = Widget::Initialize(text, x, y, width, height, parent, 0);
contextMenu = CreatePanel(x, y+25, 100, 40, gui->root);
contextMenu->Hide();
editButton = CreateButton("Edit", 0, 0, 100, 20, contextMenu, BUTTON_TOOLBAR);//just for an example, no function
removeButton = CreateButton("Remove", 0, 20, 100, 20, contextMenu, BUTTON_TOOLBAR);
ListenEvent(EVENT_WIDGETACTION, editButton, EditbuttonCallback, Self()->As<CustomMenuWidget>());
ListenEvent(EVENT_WIDGETACTION, removeButton, RemoveButtonCallback, Self()->As<CustomMenuWidget>());
return isInit;
}
static bool EditbuttonCallback(const Event& ev, shared_ptr<Object> extra)
{
auto listView = extra->As<CustomMenuWidget>();
listView->contextMenu->Hide();
Print("edit button run");
return true;
}
static bool RemoveButtonCallback(const Event& ev, shared_ptr<Object> extra)
{
auto listView = extra->As<CustomMenuWidget>();
listView->contextMenu->Hide();
Print("remove button run");
return true;
}
//Called when the mouse moves if this widget has the focus
virtual void MouseMove(const int x, const int y) {}
//Called when the mouse cursor enters the widget bounds
virtual void MouseEnter(const int x, const int y)
{
hover = true;
Redraw();
}
//Called when the mouse cursor leaves the widget bounds
virtual void MouseLeave(const int x, const int y)
{
hover = false;
Redraw();
}
//Called when the mouse button is pressed
virtual void MouseDown(const MouseButton button, const int x, const int y)
{
if (button == MOUSE_LEFT)
{
if(contextMenu->hidestate) {
contextMenu->Show();
}
else {
contextMenu->Hide();
}
}
}
//Called when the mouse button is released
virtual void MouseUp(const MouseButton button, const int x, const int y) {}
//Called when another widget becomes selected
virtual void LoseFocus() {}
//Called when mouse double-click occurs
virtual void DoubleClick(const MouseButton button, const int x, const int y) {}
//Called when mouse triple-click occurs
virtual void TripleClick(const MouseButton button, const int x, const int y) {}
//Called when widget is selected
virtual void GainFocus() {}
//Called when key is pressed
virtual void KeyDown(const UltraEngine::KeyCode key) {}
//Called when key is released
virtual void KeyUp(const UltraEngine::KeyCode key) {}
//Called for each keydown event
virtual void KeyChar(const int keychar) {}
//Called when mouse wheel turns and mouse is hovered over this widget
virtual void MouseWheel(const int delta, const int x, const int y) {}
//Called each time the widget is redrawn
virtual void Draw(const int x, const int y, const int width, const int height)
{
blocks.clear();
Vec4 color = Vec4(0.255f, 0.10f, 0.10f, 1);
if (hover) color = Vec4(0.255f, 0.255f, 0.255f, 1);
//Background rectangle
AddBlock(iVec2(0), this->size, color);
//Foreground text
AddBlock(text, iVec2(0), this->size, Vec4(1), TEXT_CENTER | TEXT_MIDDLE);
}
public:
//Constructor
CustomMenuWidget() : hover(false)
{}
friend shared_ptr<Widget> CreateCustomMenuWidget(const WString&, const int, const int, const int, const int, shared_ptr<Widget>, const CustomMenuStyle);
};
//Create function
shared_ptr<Widget> CreateCustomMenuWidget(const WString& text, const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, const CustomMenuStyle style)
{
auto widget = std::make_shared<CustomMenuWidget>();
widget->Initialize(text, x, y, width, height, parent, style);
return widget;
}
Thank you @Josh and @Dreikblack for supporting me before, i know my posts were annoying but i finally understand how widgets are created.