Listbox EditCell Highlight Q.

Hi I have the following code in my Listbox.CellBackgroundPaint which ONLY highlights the current cell that you click on (I set CLickedRow/ClickedColumn in Cellclick).

  // Get Cell Width
  Dim RW as integer = me.Column(column).WidthActual
  Dim RH as integer = me.RowHeight

  if row = ClickedRow AND column = ClickedColumn Then
    g.Transparency = 0
    g.ForeColor = &cFF3399
    g.FillRect 0,0,RW,RH
  End if

This works until I click on a cell that is Editable and then the whole row gets highlighted with some default color. I don’t want this behavior and I am struggling to find info on where this is happening/how to disable it.

Any advice would be much appreciated!
Thanks
Mike

make sure you return true / false appropriately from the various events otherwise the listbox will continue to handle them in its normal way

In my cellbackgroundpaint I return true at the end and the same for my cellclick. I assume this it not correct then for what I am trying to accomplish?

just means that normal back ground painting won’t happen

but there are lots of other events that draw or paint as well and you may need to deal with those as well

On this listbox I am using:

CellAction
CellClick (return true at the end)
CEllKeyDown(return false at end)
CellTextPaint
DoubleClick
Open

Do I need to add another event to address the background highlight only when I am editing a cell?

Thanks again Norman!

yes this is what I want and it is working this way ONLY until I edit a cell. :slight_smile: Thanks!!

Here is a picture of what I am struggling with. I don’t want the blue highlight when I am editing a cell.

So far I still can’t find a way to prevent this when editing a cell. I prevent it just fine when I am not editing.

Thanks :slight_smile:

I don’t see the return true in your code. Also, you can simplify it a bit:

if row = ClickedRow AND column = ClickedColumn Then
    g.Transparency = 0
    g.ForeColor = &cFF3399
    g.FillRect 0,0,g.Width,g.Height
End if
return true  

Thanks Tim. I have had Return True at the bottom (left it out by accident on my paste). I am working on trying to mask the row selected highlight with the background cellbackground paint color/transparency.

Ok I got it to work, but I had an interesting thing that was causing me pain. If I use very low or no transparency when coloring the background cells and then when I select the cell the two colors match thus masking my row color.

If I use say a transparency of 70 both colors do not match at all and it looks gross :wink:

This is the code with 5% transparency which works.

  
  // Get Cell Width
  Dim RW as integer = me.Column(column).WidthActual
  Dim RH as integer = me.RowHeight
 
  //Draw the HighlightColor for the Cell Outline for New Row
  if row <= CredentialGroupListBox.LastIndex then
    g.Transparency = 65
    g.PenHeight= 0
    g.PenWidth = 1
    g.ForeColor = &c000000
    g.DrawRect(0, 0, RW,RH)
    g.Transparency = 0
  end if
  
  //Add a bottom bar to even out the thickness of the last added bottom outline
  if row = CredentialGroupListBox.LastIndex+1 then
    g.Transparency = 65
    g.PenHeight= 0
    g.PenWidth = 1
    g.ForeColor = &c000000
    g.DrawLine(0, 0, RW,0)
    g.Transparency = 0
  end if
 
// **************** CODE BELOW that was causing me pain :)

  // Fill background Cell color (multicolor) of Only Added Rows
  if row <= CredentialGroupListBox.LastIndex Then
    g.Transparency = 5 // <--- If I change this to 70 along with the Selected Transparency
    If row Mod 2=0 then
      g.foreColor= &cFFFF00
    else
      g.foreColor= &cCCFFFF
    end if 
    g.FillRect 1,1,RW,RH
    g.Transparency = 0
  End if
  
  if me.selected(Row) Then
    g.Transparency = 5  // <--- If I change this to 70 it looks crazy along with the above
    If row Mod 2=0 then
      g.foreColor= &cFFFF00
    else
      g.foreColor= &cCCFFFF
    end if
    g.FillRect 1,1,RW-2,RH-2
    g.Transparency = 0
  End if
  
  Return true

So If I change both transparencies from 5 to 70 it breaks and looks almost gray. :slight_smile: I am not sure why but if you see anything please let me know :slight_smile: Thanks again everyone!

Ah I know why… I am still competing against the default Blue that the selected row is highlighting. The more transparent I make it the worse the Blue leaks through… :slight_smile: Looks like I can’t use transparency in this situation.

I just went on and picked colors that looked like the transparent shade.

Xojo has already filled the graphics object with the highlight color before it passes it to CellBackgroundPaint, so if you want to use transparency, call ClearRect before you FillRect.

Thanks TIm!!