Fix context menu position #65
This commit is contained in:
parent
c7dd248ae3
commit
40e5ce5d37
@ -156,6 +156,17 @@ void Component::SetParent(Panel* new_parent)
|
|||||||
this->_parent = new_parent;
|
this->_parent = new_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Point Component::GetScreenPos()
|
||||||
|
{
|
||||||
|
Point newPos(0,0);
|
||||||
|
if(GetParentWindow())
|
||||||
|
newPos += GetParentWindow()->Position;
|
||||||
|
if(GetParent())
|
||||||
|
newPos += GetParent()->Position;
|
||||||
|
newPos += Position;
|
||||||
|
return newPos;
|
||||||
|
}
|
||||||
|
|
||||||
// ***** OVERRIDEABLES *****
|
// ***** OVERRIDEABLES *****
|
||||||
// Kept empty.
|
// Kept empty.
|
||||||
|
|
||||||
|
@ -50,6 +50,8 @@ namespace ui
|
|||||||
virtual void TextPosition(std::string);
|
virtual void TextPosition(std::string);
|
||||||
|
|
||||||
void Refresh();
|
void Refresh();
|
||||||
|
|
||||||
|
Point GetScreenPos();
|
||||||
|
|
||||||
/* See the parent of this component.
|
/* See the parent of this component.
|
||||||
* If new_parent is NULL, this component will have no parent. (THIS DOES NOT delete THE COMPONENT. See XComponent::RemoveChild)
|
* If new_parent is NULL, this component will have no parent. (THIS DOES NOT delete THE COMPONENT. See XComponent::RemoveChild)
|
||||||
|
@ -121,7 +121,7 @@ void Label::OnMouseClick(int x, int y, unsigned button)
|
|||||||
if(button == BUTTON_RIGHT)
|
if(button == BUTTON_RIGHT)
|
||||||
{
|
{
|
||||||
if(menu)
|
if(menu)
|
||||||
menu->Show(GetParentWindow()->Position + Position + ui::Point(x, y));
|
menu->Show(GetScreenPos() + ui::Point(x, y));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user