Keeping a table cell highlighted (highlit?)

Offbeatmammal

Member
Licensed User
I have a table that I'm using to fake tabbed navigation on a smartphone (I've tried using the ControlsEx TabControl but it doesn't seem to work on smartphone?)
So I have a table across the top of the page with a cell for each tab
I have a SelectionChanged event that lets me toggle visibility on the panels I'm using for the tabs (and then I set focus to the top field in the selected panel)
But.... I can't find a way to keep the cell selected (visibly highlighted) in the table.
Table is one row deep and the header.visible is false

I'd also like to be able to move from tab (table cell) to tab and only have the focus change to the panel if I click up/down/center on the D-Pad (left/right being used to move left and right obviously) but couldn't work out what events I needed to attach to the table (and even with the focus being set turned off on the panel field the table cells didn't highlight). If we can work that out I still want to fire the SelectionChanged events to move between panels.

Hope that makes some sense!
 

Rioven

Active Member
Licensed User
Longtime User
Maybe be better if you post even portion of your code that anyone could review.

Have you already used table1.SelectCell(col,row) to highlight the cell and trigger the SelectionChanged event?
 

Offbeatmammal

Member
Licensed User
I'd tried the tblView.SelectCell(tblView.SelectedCol,tblView.SelectedRow) code to try and get it to highlight without much success.
I'd also tried using AddEvent(....,Click,....) or cMiddle etc but no luck

Source is attached... feel free to beat it up (it's weird on the desktop and only designed for 320x240 smartphone)
 

Attachments

  • simplecontact.sbp
    16.6 KB · Views: 164

Rioven

Active Member
Licensed User
Longtime User
The problem is, once focus leaves the table and focus to other controls, the highlight on cell disappears, this is at the moment the b4p tables behaves, and this also I could not solve myself for just a simple table content inputs.

:sign0006:But for your application, you may try other work-around, as sample below may help. Controls can be image controls, buttons, etc.

B4X:
'Create Form1, button0 to button3,
'left and right button arCOLs, Arraylist1, and label1
Sub Globals
   'Declare the global variables here.
COL=1
End Sub

Sub App_Start
   Form1.Show
   MouseOnButton
   BControl(COL-1) 'initialize selection
End Sub

''''''''''''''''''''''''''FOR BUTTON/PPC KEYS''''''''''''''''''''''''''''''''''''
Sub RightArrow_Click 'or driven by PPC keys
   COL = (COL ) Mod 4 + 1 'loops to right direction
   BControl(COL-1)
End Sub

Sub LeftArrow_Click 'or driven by PPC keys
   COL = (COL + 2) Mod 4 + 1 'loops to left direction
   BControl(COL-1)
End Sub
'''''''''''''''''''''''''''''''PROCESSES'''''''''''''''''''''''''''''''
Sub BControl(x)
      For i=0 To 3
      Control("button"&i,button).Color=212,208,200 
      Next
   Control("button"&x,button).Color=cGreen
            label1.Text="You are at button"&x 'or do something
End Sub

''''''''''''''''''''''''''FOR MOUSE''''''''''''''''''''''''''''''''''''
Sub MouseOnButton
   For i=0 To 3 'record button names to arraylist1
         Arraylist1.Add("button"&i)
   Next

   For i=0 To Arraylist1.Count-1 'to indicate where control mouse click
   AddEvent (Arraylist1.Item(i), click, "ButtonClick")
   Next
End Sub

Sub ButtonClick  'button control mouse click
   s = Control (Sender).Name
   For i=0 To Arraylist1.Count-1
   If s=Control(Arraylist1.Item(i)).Name Then
   COL=i+1
   BControl(COL-1)
   End If
   Next i
End Sub
 

Attachments

  • buttonnavigate.sbp
    2.1 KB · Views: 183
Last edited:

sahoopes

Member
Licensed User
Had the same problem

My solution was something like selecting another cell and then re-selecting the correct one. This works on my WM6 PPC but does not work in the desktop IDE.

table1.Focus
table1.SelectCell("AnotherColumn",1)
table1.SelectCell("TheTargetColumn",1)
 
Top