diff --git a/src/interface/Component.cpp b/src/interface/Component.cpp index e4c681157..b92543008 100644 --- a/src/interface/Component.cpp +++ b/src/interface/Component.cpp @@ -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. diff --git a/src/interface/Component.h b/src/interface/Component.h index 5ef672d54..c034952b6 100644 --- a/src/interface/Component.h +++ b/src/interface/Component.h @@ -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) diff --git a/src/interface/Label.cpp b/src/interface/Label.cpp index 4be7fb77a..e388e122f 100644 --- a/src/interface/Label.cpp +++ b/src/interface/Label.cpp @@ -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 {