规格 - 如何编辑表格的内容

发布于 2025-01-29 20:35:27 字数 114 浏览 1 评论 0原文

我有一个sptablePresenter,我想编辑单元格内容。
在许多框架中,可以直接编辑表格的内容,而无需打开新的组件(对话框或主详细信息样式)。我该如何使用规格执行此操作?

I have an SpTablePresenter and I would like to edit the cell contents.
In many frameworks it is possible to edit the contents of a table directly in place, without needing to open a new component (dialog or master-detail style). How can I do this with Spec ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

远山浅 2025-02-05 20:35:27

表格和树表中的表格中的一个机制来编辑规格中的字符串列

,可以通过声明列以编辑为编辑来编辑字符串。通过发送OnAcceptedition:,它接收两个参数,即正在编辑的对象和编辑字符串。

以下代码将显示如何完成:

app := SpApplication new.
app useBackend: #Gtk.
 
presenter := SpPresenter new.
presenter application: app.

presenter layout: (SpBoxLayout newTopToBottom
    add: (tablePresenter := presenter newTable);
    yourself).

tablePresenter 
    addColumn: (SpStringTableColumn title: 'R/O' evaluated: #key);
    addColumn: ((SpStringTableColumn 
            title: 'Editable' 
            evaluated: #value)
        beEditable; 
        onAcceptEdition: [ :anAssociation :aString | anAssociation value: aString ];
        yourself).

tablePresenter items: { 1 -> 'One'. 2 -> 'Two'. 3 -> 'Three' }.
    
presenter asWindow 
    title: 'Example editing cells';
    open

这将产生(使用GTK3后端)此输出:

< img src =“ https://i.sstatic.net/qvv9m.png” alt =“示例编辑到位”>

Tables and tree tables in Spec inplement a mechanism to edit string columns in place

in Spec, string columns can be edited by just declaring the column to be editable sending the beEditable message and adding a callback to process the edition by sending onAcceptEdition:, which receives two parameters, the object being editing and the edited string.

The following code will show how this can be done:

app := SpApplication new.
app useBackend: #Gtk.
 
presenter := SpPresenter new.
presenter application: app.

presenter layout: (SpBoxLayout newTopToBottom
    add: (tablePresenter := presenter newTable);
    yourself).

tablePresenter 
    addColumn: (SpStringTableColumn title: 'R/O' evaluated: #key);
    addColumn: ((SpStringTableColumn 
            title: 'Editable' 
            evaluated: #value)
        beEditable; 
        onAcceptEdition: [ :anAssociation :aString | anAssociation value: aString ];
        yourself).

tablePresenter items: { 1 -> 'One'. 2 -> 'Two'. 3 -> 'Three' }.
    
presenter asWindow 
    title: 'Example editing cells';
    open

This will produce (with the Gtk3 backend) this output:

example edit in place

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文