Tottel
Member
|
func() on _List
Hello Esenthel,
After Setting func(Function, T) while creating an object of type _List, that function is not called when selecting elements in the list.
Thanks!
|
|
12-08-2015 09:51 AM |
|
Zervox
Member
|
RE: func() on _List
(12-08-2015 09:51 AM)Tottel Wrote: Hello Esenthel,
After Setting func(Function, T) while creating an object of type _List, that function is not called when selecting elements in the list.
Thanks!
Neither is funcPre
|
|
12-08-2015 02:22 PM |
|
SamNainocard
Member
|
RE: func() on _List
I think, the only way right now is to detect it manually.
I used something like this.
Code:
List<TYPE>list;
void update() // put it into main update (Game.Update or other suitable)
{
if(Gui.ms()==&list)
{
if(TYPE * clicked=list()) // is valid
{
if(Ms.bp(0))
{
clickFunc();
}
}
}
}
void clickFunc();
{
LogN(S+"Clicked on Element: "+list.cur);
}
|
|
12-09-2015 08:41 AM |
|
Tottel
Member
|
RE: func() on _List
Sam: Sure, but I don't want to do that if there is a clean one-line solution that is supposed to work.
|
|
12-09-2015 08:57 AM |
|
Esenthel
Administrator
|
RE: func() on _List
Hi,
Right now func and funcPre work only for the List.sel selection, which is processed only when LIST_MULTI_SEL is enabled in List.flag
They will be called every time List.sel changes.
Code:
_List& func(void (*func)(Ptr user), Ptr user=null); // set function called when list 'sel' selection has changed, with 'user' as its parameter
T1(TYPE) _List& func(void (*func)(TYPE *user), TYPE *user ) {return T.func((void(*)(Ptr))func, user);} // set function called when list 'sel' selection has changed, with 'user' as its parameter
T1(TYPE) _List& func(void (*func)(TYPE &user), TYPE &user ) {return T.func((void(*)(Ptr))func, &user);} // set function called when list 'sel' selection has changed, with 'user' as its parameter
_List& funcPre(void (*func)(Ptr user), Ptr user=null); // set function called when list 'sel' selection is about to change, with 'user' as its parameter
T1(TYPE) _List& funcPre(void (*func)(TYPE *user), TYPE *user ) {return T.funcPre((void(*)(Ptr))func, user);} // set function called when list 'sel' selection is about to change, with 'user' as its parameter
T1(TYPE) _List& funcPre(void (*func)(TYPE &user), TYPE &user ) {return T.funcPre((void(*)(Ptr))func, &user);} // set function called when list 'sel' selection is about to change, with 'user' as its parameter
If you want to detect clicks on List elements, then I recommend doing what SamNainocard suggested
|
|
12-10-2015 08:36 AM |
|
Tottel
Member
|
RE: func() on _List
Hi Esenthel,
Isn't a list without the LIST_MULTI_SEL flag just a list with a max List.sel of 1?
I don't understand why func and funcPre would not work without multi-selection, because you would really expect it to work consistently.
Thanks!
(This post was last modified: 12-10-2015 09:28 AM by Tottel.)
|
|
12-10-2015 09:28 AM |
|
Esenthel
Administrator
|
RE: func() on _List
Hi,
List.cur is always valid (it's the keyboard cursor position)
List.sel is valid only with LIST_MULTI_SEL enabled, if it's not enabled then 'sel' will always be empty.
The comments on 'func' and 'funcPre' mention that the functions are called only when 'sel' changes.
When LIST_MULTI_SEL is disabled, then List.sel is not used at all, only List.cur is used.
|
|
12-10-2015 09:39 AM |
|
Tottel
Member
|
RE: func() on _List
I see,
Thanks Esenthel, I will use the solution from Zervox and Sam then!
|
|
12-10-2015 09:45 AM |
|
Esenthel
Administrator
|
RE: func() on _List
Next version will have:
'func' renamed to 'selChanged'
and a new:
'curChanged' method added
|
|
03-25-2016 12:29 AM |
|
Tottel
Member
|
RE: func() on _List
Works perfectly and it's much cleaner.
Thanks!
|
|
04-06-2016 04:24 PM |
|