首页 > 解决方案 > 使用退格键从 p:textEditor 中删除文本

问题描述

我想实现一种用户可以用来做笔记的便利贴功能。我通过在底部带有“保存”和“取消”按钮的对话框中打开 p:textEditor 来实现这一点。这大部分工作正常,唯一的问题是我无法使用退格键删除 textEditor 中的文本。使用 del 键删除工作正常。

这是我的代码:

打开包含 textEditor 的对话框的命令按钮:

<p:commandButton value="openPostit" widgetVar="openPostit"
                         onsuccess="PF('frmPostit').show();"
/>

对话框:

<h:form id="frmPostit">
            <p:dialog id="dlgPostit" widgetVar="dlPostit"
                      dynamic="false" modal="false"
                      fitViewport="false" resizable="true"
                      closable="true"
                      onHide="$('#frmPostit\\:quit').click();">
                <p:hotkey bind="esc" handler="PF('dlgPostit').hide();" />
                <p:outputPanel>
                        <p:textEditor id="textPostit" widgetVar="textPostit"
                                      value="#{backingbean.text}"
                                      style="vertical-align: top; height: 450px">
                        </p:textEditor>

                    <div style="position: absolute; bottom: 10px" >
                        <p:commandButton value="Save"
                                         actionListener="#{backingbean.saveText()}"
                                         accesskey="s"
                                         process="@form"
                                         icon="fa fa-check-square-o"
                                         oncomplete="PF('dlgPostit').hide();}"
                                         />

                        <p:commandButton value="Cancel" id="quit"
                                     icon="fa fa-close"
                                     process="@this" resetValues="true"
                                     immediate="true"
                                     accesskey="a"
                                     oncomplete="PF('dlgPostit').hide();" />
                    </div>
                </p:outputPanel>
            </p:dialog>
        </h:form>

知道为什么退格键不会删除 textEditor 中的文本吗?

编辑:我发现可能有趣的附加信息:我可以使用退格键(但不是文本)删除换行符

标签: jsfprimefaces

解决方案


推荐阅读