Java 为什么Gtk TextBuffer onChanged在使用setText后被调用两次?
我试图让一个函数在每次TextBuffer的内容发生变化时调用,或者使用Java 为什么Gtk TextBuffer onChanged在使用setText后被调用两次?,java,gtk,Java,Gtk,我试图让一个函数在每次TextBuffer的内容发生变化时调用,或者使用buffer.setText(“…”)或者当用户键入某个内容时调用,但是在使用setText之后,函数会被调用两次(而不是一次) 此示例打印 onChange called with onChange called with second text onChange called with onChange called with third text 知道为什么会这样吗?我正在使用java gnome 4.1和jav
buffer.setText(“…”)
或者当用户键入某个内容时调用,但是在使用setText之后,函数会被调用两次(而不是一次)
此示例打印
onChange called with
onChange called with second text
onChange called with
onChange called with third text
知道为什么会这样吗?我正在使用java gnome 4.1和java 1.8。是gtk_text_buffer_delete
和gtk_text_buffer_insert
的组合。此函数发出“删除范围”
和“插入文本”
信号。这些信号已经发出。这些处理程序发出“已更改”
因此,事实上,对于单个gtk\u buffer\u set\u文本,调用信号按以下顺序发出:
“删除范围”
“已更改”
“插入文本”
“已更改”
onChange called with
onChange called with second text
onChange called with
onChange called with third text