# Intention of \`getRowPosition(rowNum, false)\`

**URL:** <https://forum.juce.com/t/intention-of-getrowposition-rownum-false/62244>\
**Category:** General JUCE discussion\
**Created:** [July 20, 2024, 2:09am UTC](https://forum.juce.com/t/intention-of-getrowposition-rownum-false/62244 "2024-07-20T02:09:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![officialnsa](https://avatars.discourse-cdn.com/v4/letter/o/ecb155/32.png) [@officialnsa](https://forum.juce.com/u/officialnsa)\
**Post date:** [July 20, 2024, 2:09am UTC](https://forum.juce.com/t/intention-of-getrowposition-rownum-false/62244/1 "2024-07-20T02:09:07Z")

</div>

I’ve been working a lot with `ListBox` lately and have come across something that has confused me. While reading the source for `ListBox::getRowPosition()`, I got a little confused at the intention behind the `relativeToComponentTopLeft` parameter. Here’s the source for reference:

```cpp
Rectangle<int> ListBox::getRowPosition (int rowNumber, bool relativeToComponentTopLeft) const noexcept
{
    auto y = viewport->getY() + rowHeight * rowNumber;

    if (relativeToComponentTopLeft)
        y -= viewport->getViewPositionY();

    return { viewport->getX(), y,
             viewport->getViewedComponent()->getWidth(), rowHeight };
}

```

Obviously, when `relativeToComponentTopLeft` is `true`, the value you get is the position of the row relative to the top-left of the `ListBox` component itself. However, what confuses me is the value returned if you set that argument to `false`. Because the returned value still incorporates `viewport->getY()`, you’re getting the y-coordinate of the row relative to the top of the `Viewport`’s scrollable child component, plus the y-coordinate of the `Viewport` itself relative to the `ListBox`?

I’m just trying to understand what use this value could be so that I can better understand the design of the class as a whole. As far as I see it, the only values you’d want are:

1. The value returned when `relativeToComponentTopLeft` is `true`, i.e. row position relative to `ListBox`
2. The position of the row relative to the top of the viewport child, i.e. `rowHeight * rowNumber`

I just can’t puzzle out why you’d want the second value added to `viewport->getY()`. Thanks in advance for any guidance!

---

<div class="post-metadata">

**Author:** ![mathieudemange](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mathieudemange/32/13333_2.png) [@mathieudemange](https://forum.juce.com/u/mathieudemange)\
**Post date:** [July 21, 2024, 11:51am UTC](https://forum.juce.com/t/intention-of-getrowposition-rownum-false/62244/2 "2024-07-21T11:51:50Z")

</div>

Blind guess here: couldn’t that be of any use with TableListBox which can have a header?

---

<div class="post-metadata">

**Author:** ![officialnsa](https://avatars.discourse-cdn.com/v4/letter/o/ecb155/32.png) [@officialnsa](https://forum.juce.com/u/officialnsa)\
**Post date:** [July 23, 2024, 7:00pm UTC](https://forum.juce.com/t/intention-of-getrowposition-rownum-false/62244/3 "2024-07-23T19:00:44Z")

</div>

Ah, I hadn’t considered that. Not familiar enough with `TableListBox` to say for sure, but that would make sense. As I said, I just want to make sure I’m not misusing these methods.

It’d sure be nice if this parameter was documented! As it stands, I don’t feel the parameter name is clear enough.
