FlaUI icon indicating copy to clipboard operation
FlaUI copied to clipboard

How to expand a cell of table

Open bawarim opened this issue 3 years ago • 7 comments

Hi, I have a Table with cells, which can be expanded or collapsed. Please see below snapshot for the same.

image

Below is the snapshot of flaui inspect for the same. image

So kindly suggest how can I perform expand and collapse operation on these cells using FLAUI?

bawarim avatar Mar 17 '22 08:03 bawarim

It seems that the control does not support the ExpandCollapsePattern. So you probably need to fallback to Keyboard inputs or Mouse clicks at the correct location.

Roemer avatar Mar 17 '22 13:03 Roemer

It doesn't support any keyboard input. And using mouse click will result into flaky script.

bawarim avatar Mar 21 '22 11:03 bawarim

Have you tried messing with the IsEnabled?

ojonasplima avatar Mar 22 '22 12:03 ojonasplima

No, I didn't try.

bawarim avatar Mar 25 '22 09:03 bawarim

Have you tried using the LegacyIAccessible.Pattern.State? The expanded and collapsed state can be read from there. In my case, I have vertical grids with rows that are expandable in the UI but do not have the ExpandCollapse pattern and the following works for me when passing thru the GridHeader element:

            if (element.Patterns.LegacyIAccessible.IsSupported)
            {
                var currentPattern = element.Patterns.LegacyIAccessible.Pattern;
                var currentState = currentPattern.State;
                if (targetState == ExpandCollapseState.Collapsed && currentState.Value.HasFlag(AccessibilityState.STATE_SYSTEM_EXPANDED))
                {
                    currentPattern.DoDefaultAction(); //Assuming Activate expands it
                }
                else if (targetState == ExpandCollapseState.Expanded && currentState.Value.HasFlag(AccessibilityState.STATE_SYSTEM_COLLAPSED))
                {
                    currentPattern.DoDefaultAction(); //Assuming Activate expands it
                }
            }

kuskitkd avatar Apr 20 '22 20:04 kuskitkd

@kuskitkd I have tried using this solution but this also didn't worked. In my case the values for currentPattern.State are {STATE_SYSTEM_SELECTED, STATE_SYSTEM_FOCUSED, STATE_SYSTEM_FOCUSABLE, STATE_SYSTEM_SELECTABLE}.

And the value for currentPattern.DefaultAction is {Edit}

bawarim avatar May 26 '22 08:05 bawarim

Currently I am using BoundingRectangles to click on the expand/collapse icon.

Grid grd = element.AsGrid(); grd.GetRowByIndex(1).Cells[1].Click(); Rectangle rect = grd.GetRowByIndex(1).Cells[1].BoundingRectangle; Point pnt = new Point(); pnt.X = rect.X; pnt.Y = rect.Y; Mouse.Click(pnt);

bawarim avatar May 26 '22 08:05 bawarim