lclick/rclick on a button

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

User avatar
rogerdv
Quite a regular
Quite a regular
Posts: 62
Joined: Thu Mar 31, 2005 23:21
Contact:

lclick/rclick on a button

Postby rogerdv » Thu Jul 14, 2011 20:34

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.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: lclick/rclick on a button

Postby Jamarr » Thu Jul 14, 2011 22:20

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:
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

User avatar
rogerdv
Quite a regular
Quite a regular
Posts: 62
Joined: Thu Mar 31, 2005 23:21
Contact:

Re: lclick/rclick on a button

Postby rogerdv » Fri Jul 15, 2011 12:03

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?

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: lclick/rclick on a button

Postby Kulik » Fri Jul 15, 2011 12:43

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...


Return to “Help”

Who is online

Users browsing this forum: No registered users and 11 guests