Home » U++ Library support » U++ Widgets - General questions or Mixed problems » how to add runtime StaticText and hook mouse events for it
how to add runtime StaticText and hook mouse events for it [message #3366] |
Mon, 22 May 2006 10:21  |
qwerty
Messages: 130 Registered: May 2006
|
Experienced Member |
|
|
...tried few methods, but all fail, including overriding virtual metods.
Experimenting with something like that:
class myApp : public WithterminalLayout<TopWindow> { // just a plain window
public:
class Item { // class consist of two widgets
public:
bool moving; // want to move them on window :)
// only wants to move, if click on first widget
class Info : public StaticText {
public:
Item * pItem;
virtual void LeftDown(Point p, dword keyflags) {
pItem->moving = true;
}
virtual void LeftUp(Point p, dword keyflags) {
pItem->moving = false;
}
virtual void MouseMove(Point p, dword keyflags) {
if(pItem->moving) {
HSizePos().TopPos(p.y);
}
}
};
// our two widgets
Info info;
StaticText data;
Item(int x, int y, Ctrl * q) {
info.pItem = this; // ...becouse of 'moving' var
q->Add(info.LeftPos(x, 40).TopPos(y, 16));
q->Add(data.LeftPos(x + 41, 40).TopPos(y, 16));
info.SetText("box").SetFrame(ButtonFrame());
data.SetText("BOX").SetFrame(BlackFrame());
}
};
Array<Item> items;
virtual void LeftDown(Point pos, dword flags) {
items.Add(new Item((int)pos.x, (int)pos.y, this));
};
typedef myApp CLASSNAME;
myApp() {
CtrlLayout(*this, "Window title");
}
};
GUI_APP_MAIN
{
myApp().Run();
}
It wont even react on clicks.... am I missing something?
[Updated on: Mon, 22 May 2006 10:22] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Jun 06 21:57:06 CEST 2025
Total time taken to generate the page: 0.04305 seconds
|