mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #46] request for sample code on how to make selected TableCell editable for data entry #31
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#31
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @githubfanster on GitHub (Jan 29, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/46
hello! do you have any sample code on how to make a selected TableCell editable for data entry? i'm not sure what the magic incantation is, but i'm assuming a selected TableCell can be made editable?
thanks for any help!
@rivo commented on GitHub (Jan 30, 2018):
Hi,
The
Tableclass itself doesn't have editing built-in. However, theTableCellclass has the functionGetLastPosition()which tells you where on the screen the table cell was drawn.You could temporarily place an
InputFieldon top of the table at that exact position to make it look like the cell can be edited.Let me know if this helps.
@githubfanster commented on GitHub (Jan 30, 2018):
thanks for the reply. i'm not sure how to draw the InputField to screen
using the selectedCell's position. can you help?
int) {
fmt.Printf("selected row: %d, column: %d\n", row, column)
selectedCell := table.GetCell(row, column)
x, y, width := selectedCell.GetLastPosition()
inpFld := tview.NewInputField()
position on the screen?
//** do i need height info?
//** how do i draw the InputField to make it show up?
inpFld.SetRect(x, y, width, 20)
inpFld.SetText(selectedCell.Text)
})
On Tue, Jan 30, 2018 at 3:11 PM, rivo notifications@github.com wrote:
@rivo commented on GitHub (Jan 30, 2018):
You're probably going to have to use the
Pagesprimitive to superimpose the input field on the table. Here's an example of what that could look like:It's a working example. (A modification of the table demo.)
@githubfanster commented on GitHub (Jan 30, 2018):
thank you very much. that worked for me!
On Tue, Jan 30, 2018 at 5:24 PM, rivo notifications@github.com wrote: