gpui-component icon indicating copy to clipboard operation
gpui-component copied to clipboard

table: render_* trait context

Open zanmato opened this issue 1 month ago • 0 comments

Would it be possible to set the trait cx to Context<TableState<Self>> for render_td and render_th instead of App like in move_column for example? This would allow cx.listener usage inside of the render methods, for things like cell selection.

    /// Render the header cell at the given column index, default to the column name.
-    fn render_th(&self, col_ix: usize, window: &mut Window, cx: &mut App) -> impl IntoElement {
+    fn render_th(&self, col_ix: usize, window: &mut Window, cx: &mut Context<TableState<Self>>) -> impl IntoElement {
        div()
            .size_full()
            .child(self.column(col_ix, cx).name.clone())
    }

    /// Render cell at the given row and column.
    fn render_td(
        &self,
        row_ix: usize,
        col_ix: usize,
        window: &mut Window,
-       cx: &mut App,
+       cx: &mut Context<TableState<Self>>,
    ) -> impl IntoElement;

    /// Move the column at the given `col_ix` to insert before the column at the given `to_ix`.
    fn move_column(
        &mut self,
        col_ix: usize,
        to_ix: usize,
        window: &mut Window,
        cx: &mut Context<TableState<Self>>,
    ) {
    }

zanmato avatar Nov 12 '25 21:11 zanmato