[SOLVED] eventMouseButtonClick does not work

Fred

13-01-2009 19:34:54

Hi there!
I've problems to use MyGUI in my project. If I create a button and want to add a eventMouseButtonClick nothing happens, if I click on this button.
Here some of my code:

gui_ = new MyGUI::Gui();
gui_->initialise(game_env_.window, "core.xml");
MyGUI::LayoutManager::getInstance().load("EditDemo.layout");
MyGUI::ButtonPtr start_widget = gui_->findWidget<MyGUI::Button>("main_menu_start");
start_widget->setCaption("Blabla");
start_widget->eventMouseButtonClick = MyGUI::newDelegate(this, &gs_main_menu::handle_gui);

// Test-Button to see, if it works with it
MyGUI::ButtonPtr button = gui_->createWidget<MyGUI::Button>("Button", 10, 10, 300, 26, MyGUI::ALIGN_DEFAULT , "Main");
button->setCaption("exit");
button->eventMouseButtonClick = MyGUI::newDelegate(this, &gs_main_menu::handle_gui);


Are there any other thigs to do? This code is called at the begining of my class. So it wouldn't be updated all the time. But I think that's not neccessary.

Perhabs I have to say some words to my input-system. It isn't an ordinary input-system. It's simple, but too simple for GUI, i think. In my application every class has an "input-map" In this all inputs are saved and for every key there is an method which has to be called if the key was pressed. I don't have any method like "onFrameStarted" "ButtonPressed" "MouseMoved" etc.
I only have a method ist called "progress_input" in which the input maps are read and if there is an input the methods are called.
So I created a method to inject pressing the mouse button, looks like this:
void gs_main_menu::handle_mouse_pressed(const float, const OIS::MouseState &mouse_state)
{
gui_->injectMousePress(OIS::MouseEvent(game_env_.imgr->get_mouse(), mouse_state),OIS::MB_Left);
}


I update the mouse movement in every single frame in an update-method and mouse movment works fine.

But what could wrong with my code.
A few interesting things by the way:

  1. * The handle_gui-method is never called except on quit the application
    * The handle_mouse_pressed-method is called, when I press the left mouse-button
    * The MyGUI::newDelegate()-method doesn't exist in my intellisense of VC++; there are any compile errors but I can't see this method as all the other methods
    [/list:u]

    I hope you can help me! Thank you very much!
    Fred

Altren

14-01-2009 07:00:31

To have eventMouseButtonClick you need press and release mouse over same widget, so, you need to call both injectMousePressed and injectMouseReleased somewhere.
  1. * The MyGUI::newDelegate()-method doesn't exist in my intellisense of VC++; there are any compile errors but I can't see this method as all the other methods[/list:u]
I believe that it's because newDelegate actually placed in delegates namespace (MyGUI::delegates::newDelegate) and we have using MyGUI::delegates::newDelegate; in MyGUI headers.

Fred

14-01-2009 16:57:55

Oh! Okay I will check this out. Maybe I have to change my input system a bit