mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-13 22:39:44 +00:00
Clicking on an item is now detected.
Trying to have items follow the mouse position, but it doesn't work yet.
This commit is contained in:
parent
25432d97d2
commit
a6419c3596
2 changed files with 21 additions and 7 deletions
|
@ -43,7 +43,7 @@ ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Enviro
|
||||||
|
|
||||||
setText("CloseButton","Close");
|
setText("CloseButton","Close");
|
||||||
setText("TakeButton","Take All");
|
setText("TakeButton","Take All");
|
||||||
mContainerWidget->eventMouseItemActivate += MyGUI::newDelegate(this,&ContainerWindow::onSelectedItem);
|
//mContainerWidget->eventMouseItemActivate += MyGUI::newDelegate(this,&ContainerWindow::onSelectedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,std::string guiFile)
|
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,std::string guiFile)
|
||||||
|
@ -61,7 +61,7 @@ ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Enviro
|
||||||
|
|
||||||
//setText("CloseButton","Close");
|
//setText("CloseButton","Close");
|
||||||
//setText("TakeButton","Take All");
|
//setText("TakeButton","Take All");
|
||||||
mContainerWidget->eventMouseItemActivate += MyGUI::newDelegate(this,&ContainerWindow::onSelectedItem);
|
//mContainerWidget->eventMouseItemActivate += MyGUI::newDelegate(this,&ContainerWindow::onSelectedItem);
|
||||||
}
|
}
|
||||||
ContainerWindow::~ContainerWindow()
|
ContainerWindow::~ContainerWindow()
|
||||||
{
|
{
|
||||||
|
@ -128,8 +128,9 @@ void ContainerWindow::open(MWWorld::Ptr& container)
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
MyGUI::ImageBox* image = mContainerWidget->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(x, y, 32, 32), MyGUI::Align::Default);
|
MyGUI::ImageBox* image = mContainerWidget->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(x, y, 32, 32), MyGUI::Align::Default);
|
||||||
MyGUI::TextBox* text = mContainerWidget->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(x, y, 18, 18), MyGUI::Align::Default, std::string("Label"));
|
MyGUI::TextBox* text = image->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(x, y, 18, 18), MyGUI::Align::Default, std::string("Label"));
|
||||||
|
image->eventMouseButtonClick += MyGUI::newDelegate(this,&ContainerWindow::onSelectedItem);
|
||||||
|
image->eventMouseMove += MyGUI::newDelegate(this,&ContainerWindow::onMouseMove);
|
||||||
x += 36;
|
x += 36;
|
||||||
if(count % 20 == 0)
|
if(count % 20 == 0)
|
||||||
{
|
{
|
||||||
|
@ -141,7 +142,7 @@ void ContainerWindow::open(MWWorld::Ptr& container)
|
||||||
if(iter->getRefData().getCount() > 1)
|
if(iter->getRefData().getCount() > 1)
|
||||||
text->setCaption(boost::lexical_cast<std::string>(iter->getRefData().getCount()));
|
text->setCaption(boost::lexical_cast<std::string>(iter->getRefData().getCount()));
|
||||||
|
|
||||||
mContainerWidgets.push_back(image);
|
//mContainerWidgets.push_back(image);
|
||||||
|
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
|
@ -168,7 +169,19 @@ void ContainerWindow::onByeClicked(MyGUI::Widget* _sender)
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainerWindow::onSelectedItem(MyGUI::ItemBox* _sender, size_t _index)
|
void ContainerWindow::onSelectedItem(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
|
_sender->detachFromWidget();
|
||||||
|
_sender->attachToWidget(mContainerWidget->getParent()->getParent());
|
||||||
|
std::cout << mContainerWidget->getParent()->getParent()->getName();
|
||||||
|
_sender->setUserString("drag","on");
|
||||||
std::cout << "selected!";
|
std::cout << "selected!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContainerWindow::onMouseMove(MyGUI::Widget* _sender, int _left, int _top)
|
||||||
|
{
|
||||||
|
if(_sender->getUserString("drag") == "on")
|
||||||
|
{
|
||||||
|
_sender->setPosition(_left,_top);
|
||||||
|
}
|
||||||
|
}
|
|
@ -55,7 +55,8 @@ namespace MWGui
|
||||||
|
|
||||||
|
|
||||||
void onByeClicked(MyGUI::Widget* _sender);
|
void onByeClicked(MyGUI::Widget* _sender);
|
||||||
void onSelectedItem(MyGUI::ItemBox* _sender, size_t _index);
|
void onSelectedItem(MyGUI::Widget* _sender);
|
||||||
|
void onMouseMove(MyGUI::Widget* _sender, int _left, int _top);
|
||||||
|
|
||||||
//MWWorld::Ptr& mContainer;
|
//MWWorld::Ptr& mContainer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue