Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add ui.table press event listener support #346

Merged
merged 7 commits into from
Mar 8, 2024

Conversation

mofojed
Copy link
Member

@mofojed mofojed commented Mar 7, 2024

import deephaven.ui as ui
import deephaven.plot.express as dx

te = (
    ui.table(dx.data.stocks())
    .on_row_press(lambda row, data: print(f"Row Press: {row}, {data}"))
    .on_row_double_press(lambda row, data: print(f"Row Double Press: {row}, {data}"))
    .on_cell_press(
        lambda cell_index, data: print(f"Cell Press: {cell_index}, {data}")
    )
    .on_cell_double_press(
        lambda cell_index, data: print(f"Cell Double Press: {cell_index}, {data}")
    )
    .on_column_press(lambda column: print(f"Column Press: {column}"))
    .on_column_double_press(
        lambda column: print(f"Column Double Press: {column}")
    )
)

- Depends on my web PR: deephaven/web-client-ui#1857
- Passes through the on_*_press events to IrisGrid
- Tested with the snippet from the examples, ensured all events were being printed with the correct information:
```python
import deephaven.ui as ui
import deephaven.plot.express as dx

te = (
    ui.table(dx.data.stocks())
    .on_row_press(lambda row, data: print(f"Row Press: {row}, {data}"))
    .on_row_double_press(lambda row, data: print(f"Row Double Press: {row}, {data}"))
    .on_cell_press(
        lambda cell_index, data: print(f"Cell Press: {cell_index}, {data}")
    )
    .on_cell_double_press(
        lambda cell_index, data: print(f"Cell Double Press: {cell_index}, {data}")
    )
    .on_column_press(lambda column: print(f"Column Press: {column}"))
    .on_column_double_press(
        lambda column: print(f"Column Double Press: {column}")
    )
)
```
@@ -423,6 +429,60 @@ def on_row_double_press(self, callback: RowPressCallback) -> "UITable":
"""
return self._with_prop("on_row_double_press", callback)

def on_cell_press(self, callback: CellPressCallback) -> "UITable":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool stuff. As of the latest spec rework, all of these on_* should be props to the table directly.

mofojed added a commit to deephaven/web-client-ui that referenced this pull request Mar 8, 2024
- Move the doubleClick behaviour from IrisGridDataSelectMouseHandler
into GridSelectionMouseHandler, so it's baked into Grid itself
(double-clicking a grid in the styleguide was exhibiting erroneous
behaviour)
- Allow passing in mouseHandlers to IrisGrid. Will be necessary to
support deephaven/deephaven-plugins#320
- Tested using my branch for `on_row_press` support on deephaven.ui:
deephaven/deephaven-plugins#346
- Verified Linker still worked as expected
Copy link
Contributor

@bmingles bmingles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@jnumainville
Copy link
Collaborator

+2

@mofojed mofojed merged commit b805683 into deephaven:main Mar 8, 2024
12 checks passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants