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;
|
||||
}
|
||||
|
||||
Point Component::GetScreenPos()
|
||||
{
|
||||
Point newPos(0,0);
|
||||
if(GetParentWindow())
|
||||
newPos += GetParentWindow()->Position;
|
||||
if(GetParent())
|
||||
newPos += GetParent()->Position;
|
||||
newPos += Position;
|
||||
return newPos;
|
||||
}
|
||||
|
||||
// ***** OVERRIDEABLES *****
|
||||
// Kept empty.
|
||||
|
||||
|
@ -50,6 +50,8 @@ namespace ui
|
||||
virtual void TextPosition(std::string);
|
||||
|
||||
void Refresh();
|
||||
|
||||
Point GetScreenPos();
|
||||
|
||||
/* 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)
|
||||
|
@ -121,7 +121,7 @@ void Label::OnMouseClick(int x, int y, unsigned button)
|
||||
if(button == BUTTON_RIGHT)
|
||||
{
|
||||
if(menu)
|
||||
menu->Show(GetParentWindow()->Position + Position + ui::Point(x, y));
|
||||
menu->Show(GetScreenPos() + ui::Point(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user