MouseEvent

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
rtr_18
Posts: 60
Joined: Thu Jun 10, 2010 8:35 am
Location: Programmer

MouseEvent

Post by rtr_18 »

Hi!
I've implemented the circular image list in my project. Here is irrlicht forum link where I've downloaded this code:

http://irrlicht.sourceforge.net/phpBB2 ... ctureflow

I loaded this circular image list over an Image. If I click an item in this circular list, the image beneath this list has to change its color(for each element clicked, the image has to change to a corresponding color). I stored the rgb values of the color for each element in a database table.

This is my code:

Code: Select all

void CTeamSelectState::MouseEvent(CGameManager* pManager)
{
  if (pManager->getMouse() == EMIE_LMOUSE_PRESSED_DOWN )
  {
   Theme1Color = QueryColorFromTable(playerCty->getSelected()+1);
  }
  if(pManager->getMouse() == EMIE_RMOUSE_PRESSED_DOWN)
  {
   Theme1Color = QueryColorFromTable(playerCty->getSelected()-1);
  }
}
playerCty is the list variable. Here is the

Code: Select all

QueryColorFromTable() 
function:

Code: Select all

SColorf CTeamSelectState::QueryColorFromTable(s32 id)
{
 irr::core::array<irr::core::stringc> result;
 core::stringc queryStr;
 queryStr  = L"Select primaryThemeColor FROM Team WHERE Name = '";
 switch(id)
 {
 case 0:
    queryStr += L"Aus";
	break;
 case 1:
	queryStr += L"Eng'";
    break;
 case 2:
	queryStr += L"Ind'";
    break;
 case 3:
    queryStr += L"New Zealand'";
	break;
 case 4:
	queryStr += L"Pak'";
	break;
 default:
	queryStr += L"Aus'";
 }
 //queryStr += id;
 //queryStr += L" ";
 SColorf temp;
 result = SQLdb.Query(queryStr);
 temp = parseTextValueAsSColorf(result[0]);
 return temp;
}
My problem is: If I clicked outside of the list items(over some other buttons) also the color change takes place. What to do to effect color change only when a list item is clicked?
Frank Dodd
Posts: 208
Joined: Sun Apr 02, 2006 9:20 pm

Post by Frank Dodd »

This is just a suggestion without running any code and having not used this class before (looks nice though).

As CNrp2DPictureFlowis based on a listbox the click hit will be tested against the AbsoluteRect and inside a square, from a quick scan of the CNrp2DPictureFlow code it looks like all mouse clicks in that box will be processed even if they don't hit an image so if your GUI element is ontop of an area of that rectangle for aesthetic purposes.

A screenshot of your UI would be useful, perhaps the easiest solution would be to rearrange the GUI or perhaps reordering the elements would help.
rtr_18
Posts: 60
Joined: Thu Jun 10, 2010 8:35 am
Location: Programmer

Post by rtr_18 »

Post Reply