Page 1 of 1

lclick/rclick on a button

Posted: Thu Jul 14, 2011 20:34
by rogerdv
How can I tell inside the event handler if the widget received a left click or a mouse click? I need to implement different behaviours for each click in my buttons, but I havent found a clue about how to get that from EventArgs.

Re: lclick/rclick on a button

Posted: Thu Jul 14, 2011 22:20
by Jamarr
rogerdv wrote:How can I tell inside the event handler if the widget received a left click or a mouse click? I need to implement different behaviours for each click in my buttons, but I havent found a clue about how to get that from EventArgs.



:evil: :roll:

Re: lclick/rclick on a button

Posted: Fri Jul 15, 2011 12:03
by rogerdv
Thanks for the help, but the solution in the forum thread produces an error. the problem is that in the same event handler Im managing 10 buttons, so, this is the code:

Code: Select all

bool gsGame::slots_OnClick(const CEGUI::EventArgs &args)
{
    CEGUI::String buttonName = static_cast<const CEGUI::WindowEventArgs&>(args).window->getName();
    const CEGUI::MouseEventArgs& args = reinterpret_cast<const CEGUI::MouseEventArgs&>(args);
   if (buttonName=="slot1") { //execute action associated to slot
***


I get an error at "const CEGUI::MouseEventArgs& args = " saying
/home/roger/projects/ark-rpg/trunk/ark-rpg/src/gsGame.cpp|615|error: declaration of ‘const CEGUI::MouseEventArgs& args’ shadows a parameter|

Is there some way to solve this other than creating 10 different event handlers?

Re: lclick/rclick on a button

Posted: Fri Jul 15, 2011 12:43
by Kulik

Code: Select all

    bool gsGame::slots_OnClick(const CEGUI::EventArgs &args)
    {
        const CEGUI::MouseEventArgs& margs = static_cast<const CEGUI::MouseEventArgs&>(args);
        CEGUI::String buttonName = margs.window->getName();
       if (buttonName=="slot1") { //execute action associated to slot
    ***


Just give it a different name from the parameter...