programatically control columnview

Ask about the individual Gambas components here.
Post Reply
User avatar
sadams54
Posts: 139
Joined: Monday 9th July 2018 3:43am
Contact:

programatically control columnview

Post by sadams54 »

I have noticed an issue with columnview on fedora tablets. Making a selection does not select an item but instead brings up the on screen keyboard. I do not care why or how this happens I am assuming an issue in fedora.
What I want to do is create a tablet mode giving me extra buttons on the screens with columnviews which will move the selection (not the item) up and down the list. I do not know what is in the list and the keys are not sequential.
For the life of me I can't find a way to do this. below is example code using non existing keywords but you will get the idea of what i want to do. Question is how?

public sub button_up_Click()

columview.selecteditem.selectnext

end sub

the idea of this would be to move the internal cursor and the view of the user to show the next item in the list has been selected. Is there a simple way?
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: programatically control columnview

Post by BruceSteers »

sadams54 wrote: Monday 16th January 2023 8:42pm I have noticed an issue with columnview on fedora tablets. Making a selection does not select an item but instead brings up the on screen keyboard. I do not care why or how this happens I am assuming an issue in fedora.
What I want to do is create a tablet mode giving me extra buttons on the screens with columnviews which will move the selection (not the item) up and down the list. I do not know what is in the list and the keys are not sequential.
For the life of me I can't find a way to do this. below is example code using non existing keywords but you will get the idea of what i want to do. Question is how?

public sub button_up_Click()

columview.selecteditem.selectnext

end sub

the idea of this would be to move the internal cursor and the view of the user to show the next item in the list has been selected. Is there a simple way?
You must use (and read up on) the "internal cursor"
https://gambaswiki.org/wiki/comp/gb.qt4/columnview

Eg..

Public Sub btnMoveUp_Click()

  If ColumnView1.MoveCurrent() Then Return  ' move cursor to current item, MoveCurrent() returns true if there is no current item

  If ColumnView1.MovePrevious() then Return  ' if it returns true we are at top.

  ' All okay so select the Views internal cursor "Item" property
  ColumnView1.Item.Selected = True

End


If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: programatically control columnview

Post by BruceSteers »

I may have misunderstood.
When you say don't want to move the "Item" did you mean internal cursor "Item" property ?

or you don't want to "move" the list contents but just select the next up in which case the above code is a way.

Other thoughts.
using the Scroll method to move the list.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: programatically control columnview

Post by BruceSteers »

Note there are differences between ColuumnView.MovePrevious() and ColumnView.MoveAbove()

but suffice to say moving the internal cursor around is invisible to the user. you can use any combinations of the Movexxx commands to get it where you want then use the ColumnView.Item property to do something like select it or get it's data for a tooltip or something,
If at first you don't succeed , try doing something differently.
BruceS
User avatar
sadams54
Posts: 139
Joined: Monday 9th July 2018 3:43am
Contact:

Re: programatically control columnview

Post by sadams54 »

I think I understand. I was looking up columnview but nothing was jumping out at me. gambas is such a simple language that I sometimes can't think simple enough to make something work. I will try what you suggested. you understood right the first time.
User avatar
sadams54
Posts: 139
Joined: Monday 9th July 2018 3:43am
Contact:

Re: programatically control columnview

Post by sadams54 »

The solution was not quite right but lead me the right path. I posted below the actual working code for those that may need. I made it a public sub so it can be called from several places in the project using any columnview.

The button down is the same just replace LV.MovePrevious() with LV.MoveNext
As always thank you for the help

Code: Select all

Public Sub LVButtonUp(ByRef LV As ColumnView)
  
  If LV.MoveCurrent() Then ' sets the cursor to current select, if nothing is selected the next line is called which sets the first item in list active
    LV.MoveFirst()
  Else 
    If LV.MovePrevious() Then Return  ' moves cursor to previous item. if already there it exits
  Endif 
  LV.Item.Selected = True  ' selects the current item
  LV.Item.EnsureVisible    ' very important it shows the item is selected to the user.

End
Post Reply