Charrua Posted July 22, 2017 Share Posted July 22, 2017 I started another thread (https://www.leadwerks.com/community/topic/16553-handling-widgets-created-cpp-side-and-lua-side/) because i started with a gui in lua and then has the need to create and handle some widgets in cpp code, i had some troubles and guessed that the problem was in a bad parameter usage/passage. So I decided to make it work only in cpp code and i found that the test (event->source == butt1) never gets true, the same problem that i have when calling a method from lua passing the event peeked from the queue. Relevant parts of my code: /* globals */ GUI* gui; Widget* butt1; /* in App::Start */ gui = Leadwerks::GUI::Create(context); butt1->Button("Quit",30,30,100,50,gui->GetBase()); /* function to process events */ bool App::ProcessEvent(Event* event){ if (event->id == Event::WidgetAction) { System::Print("widget action!"); if (event->source == butt1) { System::Print("butt1 pressed"); butt1->Hide(); return false; //quit } } return true; } inside App::Loop while (EventQueue::Peek()){ System::Print("event queue peek"); Event event = EventQueue::Wait(); if (ProcessEvent(&event)==false) return false; } what am I doing wrong? thanks in advance Juan Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
GorzenDev Posted July 4, 2018 Share Posted July 4, 2018 at a first glanse i would say. This: butt1->Button("Quit",30,30,100,50,gui->GetBase()); Should be this: butt1 = Widget::Button("Quit",30,30,100,50,gui->GetBase()); Also i advice to always add a panel script to your gui when you create one. This neutralizes certain problems you could come across. gui = GUI::Create(context); gui->GetBase()->SetScript("Scripts/GUI/Panel.lua"); gui->GetBase()->SetObject("background", new Vec4(0,0,0,0)); Quote Link to comment Share on other sites More sharing options...
aiaf Posted July 4, 2018 Share Posted July 4, 2018 while (EventQueue::Peek()) { auto event = EventQueue::Wait(); if (event.id == Event::WidgetAction) { if (event.source == button) { I have this in main loop keeping things simple. Worse case use debugger to see what is happening in ProcessEvent. Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station Link to comment Share on other sites More sharing options...
Charrua Posted July 4, 2018 Author Share Posted July 4, 2018 thank's I test the panel thing as GrozenDev suggested and works! but.. always a but i found other problem, not related with the gui itself.., it's related to latest beta, visual studio 2017.. don't know exactly ... will see Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
ScarPunk Posted January 29, 2020 Share Posted January 29, 2020 Thanks i found my error it was Leadwerks::Widget::Button("", (this->window->GetWidth() / 2) + 100, 250, 100, 55, panel); TO Leadwerks::Widget::Button("", (this->window->GetWidth() / 2) + 100, 250, 100, 55, gui->GetBase()); 1 Quote ART CODE SOUND Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.