programatically control columnview

Post

Posted
Rating:
#1 (In Topic #973)
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 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?
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’

sadams54 said

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"
/comp/gb.qt4/columnview - Gambas Documentation

Eg..

Code (gambas)

  1.  
  2. Public Sub btnMoveUp_Click()
  3.  
  4.   If ColumnView1.MoveCurrent() Then Return  ' move cursor to current item, MoveCurrent() returns true if there is no current item
  5.  
  6.   If ColumnView1.MovePrevious() then Return  ' if it returns true we are at top.
  7.  
  8.   ' All okay so select the Views internal cursor "Item" property
  9.   ColumnView1.Item.Selected = True
  10.  
  11.  
  12.  
  13.  
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
 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,
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
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

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
Online now: No Back to the top
1 guest and 0 members have just viewed this.