Recent

Author Topic: TListView - how to deterimine selected column (without mouse!)  (Read 1332 times)

prof7bit

  • Full Member
  • ***
  • Posts: 161
TListView - how to deterimine selected column (without mouse!)
« on: September 10, 2021, 04:59:43 pm »
I have a TListView with style vsReport, it has multiple columns.

When it has focus I can move around it with the arrow keys, not only up down through the rows but also left right through the columns. Now I want to press enter on the current selection and depending on which column I am in different things should happen.

I already did this with doubleclick and with right click by using the mouse position and the column widths, but now (because I am keyboard centric and it would really speed up the workflow) i would also like to be able to start the double-click action with the enter key.

But I cannot for the life of me figure out how to get the currently selected column from the listview!

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: TListView - how to deterimine selected column (without mouse!)
« Reply #1 on: September 10, 2021, 05:38:52 pm »
When it has focus I can move around it with the arrow keys, not only up down through the rows but also left right through the columns.
How do you achieve to move the selection into the subitem columns?

prof7bit

  • Full Member
  • ***
  • Posts: 161
Re: TListView - how to deterimine selected column (without mouse!)
« Reply #2 on: September 10, 2021, 07:08:22 pm »
When it has focus I can move around it with the arrow keys, not only up down through the rows but also left right through the columns.
How do you achieve to move the selection into the subitem columns?

Oh, I just noticed it seems this is a Qt only thing! A few minutes ago I compiled it against GTK2 and I cannot move the selection horizontally at all.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: TListView - how to deterimine selected column (without mouse!)
« Reply #3 on: September 10, 2021, 07:12:57 pm »
Oh, I just noticed it seems this is a Qt only thing! A few minutes ago I compiled it against GTK2 and I cannot move the selection horizontally at all.
Win32 can also do that.
With some extra effort the similar functionality can be implemented on Cocoa.

But that certainly turns ListView into GridView. Where it's no longer a list of items, but rather a matrix of data.

Not a bad thing, if you ask me, but implementing on platforms without native support (i.e. Gtk2) might not be possible at all.

As an initial implemented, I'd recommend to create some sort of the class helper that the method like GetSelectedColum() or GetSelectedRect().
« Last Edit: September 10, 2021, 07:15:08 pm by skalogryz »

prof7bit

  • Full Member
  • ***
  • Posts: 161
Re: TListView - how to deterimine selected column (without mouse!)
« Reply #4 on: September 10, 2021, 07:29:20 pm »
But that certainly turns ListView into GridView. Where it's no longer a list of items, but rather a matrix of data.

I think I'm going to use a TStringGrid, because it actually really is a table of data and the user must clearly see which column he has clicked or selected because I have separate context menus and separate editors for separate columns, one of them even needs an entire form to edit and validate the value.
« Last Edit: September 10, 2021, 07:33:20 pm by prof7bit »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: TListView - how to deterimine selected column (without mouse!)
« Reply #5 on: September 10, 2021, 07:37:03 pm »
Win32 can also do that.
I'm wrong. win32 cannot do that either.

 

TinyPortal © 2005-2018