Check for hovering a row of a table.

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
Andrey01
Posts: 57
Joined: Mon Jul 27, 2020 9:08 pm

Check for hovering a row of a table.

Post by Andrey01 »

How to check whether a row of a table (IGUITable class) is hovered? I can not find any suitable method in that class for doing that.
CuteAlien
Admin
Posts: 9646
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Check for hovering a row of a table.

Post by CuteAlien »

Yeah, doesn't have a function for that yet. Would need something like listbox has with getItemAt.

Internally it uses:
Selected = ((ypos - AbsoluteRect.UpperLeftCorner.Y - ItemHeight - 1) + VerticalScrollBar->getPos()) / ItemHeight;

I think you can access all those values, so as workaround you can calculate it like this.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Andrey01
Posts: 57
Joined: Mon Jul 27, 2020 9:08 pm

Re: Check for hovering a row of a table.

Post by Andrey01 »

I seem to know how it may be implemented. It is derived enough easily. The steps are following:
  • 1. Check whether an user is currently hovering a table element at all (getHovered()).
    2. Get current position of the mouse cursor (getPosition()).
    3. Run all table rows and get its core::vector2d (I`m not sure if there is a way to get it).
    4. Check whether the cursor position is inside the rectangle (isPointInside()).
    5. If isPointInside returns true, it means the row is hovered!
However, I doubt about step 3 as like it is impossible to get a pointer or ref to row`s rectangle by its index.
Post Reply