anthony.liot Posted November 7, 2013 Share Posted November 7, 2013 Hi,I am doing drag and drop with Unigine, and I want detect when I drop, if I am over GUI or not. What is the better way for do that with UnigineScript ?? Thanks Tony Link to comment
unclebob Posted November 8, 2013 Share Posted November 8, 2013 Hi Tony! Have you looked at samples/widgets/sprite_03 sample? Link to comment
anthony.liot Posted November 8, 2013 Author Share Posted November 8, 2013 Hi Andrey, I will go to look :) Thanks Link to comment
unclebob Posted November 8, 2013 Share Posted November 8, 2013 You're welcome. :) I'll wait for your feedback before I resolve this topic. Link to comment
anthony.liot Posted November 8, 2013 Author Share Posted November 8, 2013 Unfortunately, Andrey doesn't work for us, The sample show the drag and drop between Widget.We want drag and drop between Widget and "viewport" (without gui). Looking other sample we will try with the other event ENTER and LEAVE, may be that can work. Tony Link to comment
unclebob Posted November 12, 2013 Share Posted November 12, 2013 Hi Tony, Did you get any results on drag'n'drop feature? Link to comment
anthony.liot Posted November 12, 2013 Author Share Posted November 12, 2013 Hi Andrey, Unfortunately, it's no so easy to add it inside our code, because we need to change a lot of code adding many callback .... for quick result we choose other option, we have a list of our Widget and when we receive the release of the mouse, we check for each widget the position of the mouse and the position of the widget. It's not the better way to do it, but could be work quickly. Link to comment
ivan.cuevas Posted November 12, 2013 Share Posted November 12, 2013 We use these functions /* */ int mouse_is_over_unigine_widget(Widget w) { if(w.isHidden()) return 0; int mx= w.getMouseX(); int my= w.getMouseY(); return ((mx > 0) && (my > 0) && (mx < w.getWidth()) && (my < w.getHeight())); } /* */ int mouse_is_over_any_unigine_widget() { forloop(int i=0;engine.gui.getNumChilds()) { if(mouse_is_over_unigine_widget(engine.gui.getChild(i))) return 1; } return 0; } 1 Link to comment
anthony.liot Posted November 12, 2013 Author Share Posted November 12, 2013 Thanks Ivan to share !!! Link to comment
ly.wu Posted June 8, 2020 Share Posted June 8, 2020 hello, Is there a better solution to this problem now? i want to detect my mouse over gui widget or in viewport. Link to comment
david.cambre Posted August 8, 2020 Share Posted August 8, 2020 Hi, I thought id do an update for v2.12.01 C# component system, because it is not one on one conversion. public WidgetButton button; button = new WidgetButton("button text"); Gui gui = Gui.Get(); gui.AddChild(button,Gui.ALIGN_LEFT); public static bool mouse_is_over_unigine_widget(Widget w) { if (w.Hidden) return false; bool r = ( (w.MouseX > 0 ) && (w.MouseY > 0 ) && (w.MouseX < w.Width) && (w.MouseY < w.Height) ); return r; } public static bool mouse_is_over_any_unigine_widget() { for (int i = 0; i < Gui.Get().NumChildren; i++) { if(mouse_is_over_unigine_widget(Gui.Get().GetChild(i))) return true; } return false; } Link to comment
Recommended Posts