About Store Forum Documentation Contact



Post Reply 
How to check if clicked on specific list element?
Author Message
Eric Offline
Member

Post: #1
How to check if clicked on specific list element?
As in subject, how can i check if I've clicked with specific mouse button on the given list element?

Regards,
Eric 'Eri' Przychocki
ourgames.eu
03-12-2014 12:58 PM
Find all posts by this user Quote this message in a reply
Ogniok Offline
Member

Post: #2
RE: How to check if clicked on specific list element?
Code:
if(Ms.bp(0)) //If LMB was pressed in this frame
{
   Int index = list.visToAbs(list.cur);
}

Check out tutorial Gui/List
03-12-2014 07:43 PM
Find all posts by this user Quote this message in a reply
Eric Offline
Member

Post: #3
RE: How to check on which list element clicked?
Thank you but this won't work wink This will give me absolute index of current list element everytime I click LMB. I need to know on which element I've clicked with specific mouse button (let's say RMB for instance) to call appropriate function with this element (object) as an argument.

P.S. I've changed the thread subject to be more clear.

Regards,
Eric 'Eri' Przychocki
ourgames.eu
(This post was last modified: 03-12-2014 08:25 PM by Eric.)
03-12-2014 08:23 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: How to check if clicked on specific list element?
If you want RMB then it's Ms.bp(1)?
Also you can do:
List<TYPE> list;
if(TYPE *type=list())
03-12-2014 09:39 PM
Find all posts by this user Quote this message in a reply
Eric Offline
Member

Post: #5
RE: How to check if clicked on specific list element?
Esenthel, thanks for the tip. In state update I do:
Code:
if(Ms.bd(0) && Ms.test(list.screenRect()))
/* something with the list element */

Also, I discovered that _List::func user function is, I guess, called only when "Memc sel" has changed and not when "Int cur" has. Is that true? Either way, my custom function doesn't get called when I change the selection.

Regards,
Eric 'Eri' Przychocki
ourgames.eu
(This post was last modified: 03-13-2014 06:59 PM by Eric.)
03-13-2014 06:56 PM
Find all posts by this user Quote this message in a reply
Ogniok Offline
Member

Post: #6
RE: How to check if clicked on specific list element?
As far as I remember you can check if gui obj has mouse focus by:
Code:
if(Gui.ms() == &list)
{
   //Some code
}

So you're code would look like this:
Code:
if(Ms.bp(0)) //Change to 1 if you want RMB
{
   if(Gui.ms() == &list) //If list has mouse focus
   {
       if(TYPE *object = list())
       {
           YourFunction(object);
       }
   }
}
03-13-2014 07:38 PM
Find all posts by this user Quote this message in a reply
Post Reply