noob with muliColumnList

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

kazmii
Just popping in
Just popping in
Posts: 6
Joined: Thu Nov 23, 2006 10:18

noob with muliColumnList

Postby kazmii » Wed Jan 10, 2007 10:54

hey guys,

are there some people who can speak French here ? because i m not very good in English :oops:

i will try to explain my problem in English.
i have used a multicolumnlist to make a menu of deferent game in a server
like that :

id name
0 1Game
1 2Game
... ...


i try to :
-make the multicolomnlist clickable
-get the id and the name of game which are clicked on by a user.

but i don't find the good functions in the class of multicolumnlist.
Can someone help me please ?

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Wed Jan 10, 2007 14:24

You could subscribe to the mouse double click event and in response to that event you would retrieve the selected row. This code is taken from WidgetGalore

Code: Select all

// Retrieve the value of the selected item from column A
ListboxItem* listboxItem = multiColumnList->getFirstSelectedItem();
uint valueColumnA = listboxItem->getID();

// Retrieve the value of the selected item from column B
listboxItem = multiColumnList->getNextSelected(listboxItem);
uint valueColumnB = listboxItem->getID();

// Retrieve the value of the selected item from column C
listboxItem = multiColumnList->getNextSelected(listboxItem);
uint valueColumnC = listboxItem->getID();

kazmii
Just popping in
Just popping in
Posts: 6
Joined: Thu Nov 23, 2006 10:18

Postby kazmii » Wed Jan 10, 2007 15:55

thank you very much I will test immediately :D

kazmii
Just popping in
Just popping in
Posts: 6
Joined: Thu Nov 23, 2006 10:18

Postby kazmii » Fri Feb 09, 2007 10:16

hello it's me

my projet using cegui become start to be good
but i have some bug and one of them is about multicolumnlist whit the methode getFirstSelectedItem :
sometime when a user clic on the multicolmnlist if there are no item in the multicolmnlist the program crash, i think it's because i don't make a test to see if there is a item selected befor
and the problem is I don't find an attribut in the class like a booleen to say if there is a item selected

mabye i have'nt se the attribut mabye It doesn't exist
Can someone help me plz ?
thanks in advance

S.KaZ

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Fri Feb 09, 2007 11:28

If there is nothing selected then getFirstSelectedItem() returns a null pointer, which should be why you are crashing:

Code: Select all

// Retrieve the value of the selected item from column A
ListboxItem* listboxItem = multiColumnList->getFirstSelectedItem();
if(listboxItem == 0)
{
  // There is nothing selected
}
else
{
  uint valueColumnA = listboxItem->getID();
}

kazmii
Just popping in
Just popping in
Posts: 6
Joined: Thu Nov 23, 2006 10:18

Postby kazmii » Sun Feb 11, 2007 13:00

thank you !! it's run very well now :)

olethros6
Just popping in
Just popping in
Posts: 2
Joined: Sun Feb 11, 2007 00:06

Postby olethros6 » Sun Feb 11, 2007 18:31

Hello all, another noob here full of ambition and questions.

There is one problem with the method described above. Consider the following scenario: The multicolumnlist is larger than the current number of rows, you single-click on a row hence selecting it, then you double-click on the empty space and the event will get triggered and work on the selected data. Obviously that's not what you wanted. So how can you check that the cursor is indeed over the selected row?

Things would be simple if multicolumnlist used an itemlistbox and itementries but from what I've seen this is not the case. Correct me if I'm wrong.

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Sun Feb 11, 2007 21:27

Hi,

that's a good question! ;-)

You might try the following: a Window (the base class) has a method 'virtual bool isHit (const Vector2 &position) const' where the given position is usually the mouse X and Y. You might try this (i haven't tried):

... in your selection-changed handler ---
// Store the selected item, if any
m_selectedItem = multiColumnList->getFirstSelectedItem();

... then in your double-click handler...
if (m_selectedItem && m_selectedItem.isHit (mousePos)){
// user double-clicked the selected item
}
else{
// deny?
}

You should create the mousepos vector yourself.

HTH and good luck!

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Sun Feb 11, 2007 22:23

scriptkid wrote:if (m_selectedItem && m_selectedItem.isHit (mousePos)){

I don't know if i am right, but i remember in c++ the condition check order in an if is not defined, so it might be that

Code: Select all

m_selectedItem.isHit (mousePos)

is checked before

Code: Select all

m_selectedItem

is checked. That's why i avoid such if's.

Please correct me if i'm wrong, I would change all my code because

Code: Select all

if (m_selectedItem && m_selectedItem.isHit (mousePos)){


looks better then

Code: Select all

if( m_selectedItem ) {
    if( m_selectedItem.isHit (mousePos)) {
         /* code1 */
    } else {
         /* code2 */
    }
} else {
     /* same code2 */
}

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Mon Feb 12, 2007 12:43

Rather than listening for the double-click event on the multi-column list you could listen on its children, the listboxtextitem. When one is selected you would then figure out which row is activated and continue from there. This is not a "better" approach, simply a "different" one.

olethros6
Just popping in
Just popping in
Posts: 2
Joined: Sun Feb 11, 2007 00:06

Postby olethros6 » Mon Feb 12, 2007 17:55

Hi again and thanks for the replies.

There is one thing I don't understand regarding both solutions. According to the API reference, "ListboxTextItem" class does not seem to derive from "Window" class. So, it shouldn't be able to use Window::isHit() or EventSet::subscribeEvent(). This is exactly why I suggested that MultiColumnList should be using ItemEntries.

So what am I missing here?


Return to “Help”

Who is online

Users browsing this forum: No registered users and 4 guests