Tableview edit cell

Post

Posted
Rating:
#1 (In Topic #1445)
Regular
Andreas_K is in the usergroup ‘Regular’
Hello, since i updatet Gambas, i cannot edit with the old way the cell of a Tableview (like: https://forum.gambas.one/viewtopic.php?t=1212

Code (gambas)

  1. Public Sub TablePesticide_Click(Optional iRC As Integer[] = [-1, -1])
  2.  
  3.    If TablePesticide.Row = -1 Then Return
  4.    If TablePesticide.Column <> 3 And TablePesticide.Column <> 5 Then Return
  5.  
  6.    ' If iRC[0] <> -1 Then TablePesticide.moveto(iRC[0], iRC[1])
  7.  
  8.    Dim TextBox1 As Textbox
  9.  
  10.    TablePesticide.MoveTo(TablePesticide.Row, TablePesticide.Column)
  11.    TablePesticide.Edit
  12.  
  13.    TextBox1 = TablePesticide.Editor
  14.  
  15.    TextBox1.SelectAll
  16.  
  17.    Dim hObs As Observer
  18.    hObs = New Observer(TextBox1) As "Mousevent"
  19.    'Only way to get Mouse down from Textbox1
  20.  

Until now this worked, now on Textbox1.SelectAll i get null Object, commentet out nothing happens…
What i make wrong?
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
But TextBox1 is not created

You must create it.

Code (gambas)

  1.    Dim TextBox1 As Textbox
  2.   TextBox1 = New TextBox(Me)
  3.   TextBox1.Visible = False
  4.  
  5.  

And TextBox1 = TableView1.Editor seems backwards

it should be

TableView1.Editor = TextBox1
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
Andreas_K is in the usergroup ‘Regular’
I get Tableview.editor is read only.
Online now: No Back to the top

Post

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

Andreas_K said

I get Tableview.editor is read only.

Aah yes sorry i confused it with EditWith method.

TableView.Editor is for getting the control used with TableView.EditWith() TableView.Edit

Maybe whoever wrote that example can explain what it's doing.

I'm guessing it's using TableView default editor that is probably a textbox.
But for some reason in new gambas it's not created yet.

Maybe if you use Wait 0.1 after TableView.Edit to give the textbox chance to create.

Code (gambas)

  1.    TablePesticide.Edit
  2.    Wait 0.1
  3.    TextBox1 = TablePesticide.Editor
  4.  
Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
Andreas_K is in the usergroup ‘Regular’
Thanks, but it still NULL OBJECT.... will not be createt...
Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’
i just updated to latest gambas and tried this code…

Code (gambas)

  1. Public Sub TableView1_Click()
  2.  
  3.  
  4.   If TableView1.Column = 0 Then
  5.     TableView1.Edit
  6.     tb = TableView1.Editor
  7.     tb.SelectAll
  8.  
  9.  

Works as expected, text is selected.
I'm not sure why it is not working for you.
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’
Try this to test it's actually using a textbox…

Code (gambas)

  1.  
  2.     TableView1.Edit
  3.  
  4.   Debug TableView1.Editor
  5.  
  6.  
it should print something like..
Form1.TableView1_Click.47: (TextBox 0x565b829f8028)

Maybe its not using a textbox as it also can use combobox?
Online now: No Back to the top

Post

Posted
Rating:
#8
Guru
BruceSteers is in the usergroup ‘Guru’
 I think we will need an example project.

seems to work as expected here so we need to figure out why it's not for you.

Does the Textbox to edit the fields actually appear?
I suspect editing is somehow broken as you say "nothing happens"
Online now: No Back to the top

Post

Posted
Rating:
#9
Regular
Andreas_K is in the usergroup ‘Regular’
 FNewEntry.TablePesticide_Click.1345:

No Textbox appears.
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
I could not get BruceS' code to work completely. The editor appears but the text was not selected.
Here's a bit of code I wrote (don't worry, be happy  ;) ) that does work, the editor appears and all the text is selected.

Code (gambas)

  1. Public Sub tvwData_Click()
  2.  
  3.   Dim ctl As Object
  4.  
  5.   Select tvwData.Column
  6.     Case 0
  7.       ctl = New TextBox(tvwData)
  8.       ctl.Text = tvwData[tvwData.Row, 0].Text
  9.       ctl.SelectAll
  10.       tvwData.EditWith(ctl)
  11.     Case 1
  12.       ......

Now, a bit of theory…

When Edit/EditWith is executed,  the Gambas GUI starts doing its' stuff. The "Editor" is a Control entirely within the GUI component. When you try and "get at it" in the lines following the Edit/EditWith in your code it is going to have no affect on what the GUI component is doing at that time. It has probably already displayed it and is waiting for input, you can't change it. So the only way to affect what is being displayed is like the above code i.e. you need to set it up before  asking the GUI to do its' stuff and use EditWith not Edit. Also note that the control is initially typed as an anonymous Object not as Control or some specific Control.

I think TableView.Editor is only really for use in the TableView_Save() method so you can get the result of the users interaction.
Dat's what I think anywho.

b

Online now: No Back to the top

Post

Posted
Rating:
#11
Regular
Andreas_K is in the usergroup ‘Regular’
 Thanks, but is also not working, i can't see any editorbox or textbox.
Online now: No Back to the top

Post

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

Andreas_K said

Thanks, but is also not working, i can't see any editorbox or textbox.

Make a sample project showing the problem Andreas and post it here.

1 of 2 things happen when you do that….
Either you find you cannot reproduce the problem in your example program and it helps you find where your main program is going wrong.

Or you CAN reproduce the problem and WE can then help you find the error :)

But without seeing your code we cannot guess as to why your editor (textbox) does not show.

Also are you using X11 or wayland?
Online now: No Back to the top

Post

Posted
Rating:
#13
Regular
Andreas_K is in the usergroup ‘Regular’
Thanks everyone! With your tips i found it.

Code (gambas)

  1.       .[irow, 5].Foreground = &H2727A0
  2.       .[irow, 6].Text = GridPesticide[GridPesticide.Row, 6].Text
  3.       .[irow, 7].Foreground = &HC0176B
  4.       .[irow, 7].Text = GridPesticide[GridPesticide.Row, 7].Text
  5.       .[irow, 7].tag = bBad
  6.       .[irow, 8].Text = GridPesticide[GridPesticide.Row, 9].Text
  7.       .[irow, 8].tag = GridPesticide[GridPesticide.Row, 10].Text
  8.       .Rows[irow].Height = 24   '<---------
  9.    End With
  10.  

Since the update the row.height on the insertet row cannot be lower than 25, otherwise this error occur, also with higher values the text in the editorbox isnot readable. Can anyone reproduce this also? I use Ubuntu 24.10 with wayland.
Online now: No Back to the top
1 guest and 0 members have just viewed this.