DearPyGui
DearPyGui copied to clipboard
table cell binding
When binding items in a table cell, like text items with a click handler. I can click on the text and then do something. However, if I miss the text item and click on the cell, nothing happens so I tried binding the cell also. However, the table cell binding is currently not allowed. If the text item is empty, then the cell cannot be edited unless its padded with spaces.
Describe the solution you'd like Allow for table cell binding to a handler.
Describe alternatives you've considered My work around is to pad all text with spaces so that clicking anywhere in the cell/row results in a call to the handler.
I just encountered this too. I also tried to bind the click handler to the row but I get an error that click handler cannot be bound to a row.
The problem with this is that there's no such widget as a "table cell" in Dear ImGui. Table just provides grid layout and you put widgets into that layout. Whatever area of the cell is not occupied by a widget, won't be processed at all: there's no way to determine if that area got hovered or clicked.
A workaround for this is to use a button instead of text. Use themes to make its background transparent and to align text to the left. With buttons, you can fill the entire cell, and capture clicks and hovers on that cell.
Implementation note: While it should be possible to add handlers to dpg.table_cell
, this might degrade performance because it would require a call to ImGui::ItemAdd()
and then a set of tests where previously the code did nothing of the sort. Also, might cause conflicts e.g. with buttons in table cells (don't know for sure) because the button will overlap with that ItemAdd
area.