Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么Gtk TextBuffer onChanged在使用setText后被调用两次?_Java_Gtk - Fatal编程技术网

Java 为什么Gtk TextBuffer onChanged在使用setText后被调用两次?

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

我试图让一个函数在每次TextBuffer的内容发生变化时调用,或者使用
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