在 GTK+ 中设置光标颜色3
我正在寻找设置 GtkTextView 光标颜色。我知道我可以通过 gtk_rc_parse 命令或类似的命令来完成此操作,但文档说这些命令已被贬值,我不认为 GtkCssProvider 支持光标颜色。是否可以通过其他方式设置?
I'm looking to set a GtkTextView cursor-color. I know I can do it through the gtk_rc_parse command or something similar, but the documentation says that those commands are depreciated, and I don't think GtkCssProvider supports cursor-color. Is it possible to set it some other way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可以在 gtk3 中使用 CSS 来完成。 GtkTextView 本身没有“光标颜色”属性。您必须在层次结构中上升到 GtkWidget,它确实具有该属性,并且由于 GtkTextView 是 GtkWidget 的一种类型,因此您可以通过 GtkWidget 设置 GtkTextView 的样式。所以你使用: -GtkWidget-cursor-color
这对于其他属性也是如此。例如,“焦点线宽度”。该属性由多个小部件共享,包括 GtkButton 和 GtkTreeView 的行。
文档中为特定小部件列出的样式属性必须以:-widgetname-
例如,为 GtkTextView 列出的唯一样式属性是“error-underline-color”,因此在 CSS 中您将使用:-GtkTextView-error- underline-color
下面是在 GtkTextView 中更改“cursor-color”和其他属性的示例:
http://www.gtkforums.com/viewtopic.php?f=988&p=195276=Styling+a+GtkTextView+with+Gtk3+and+Css%3A#p195276
This can be done in gtk3 with CSS. GtkTextView itself doesn't have a "cursor-color" property. You must go up in hierarchy to GtkWidget which does have that property and since GtkTextView is a type of GtkWidget you can style the GtkTextView through GtkWidget. So you use: -GtkWidget-cursor-color
This is true for other properties as well. For instance, "focus-line-width". This property is shared by several widgets including GtkButton and the rows of a GtkTreeView.
The style property listed for a specific widget in the documentation must be preceded by: -widgetname-
For instance, the only style property listed for GtkTextView is "error-underline-color" So in the CSS you would use: -GtkTextView-error-underline-color
Here's an example of changing "cursor-color" and other properties in a GtkTextView:
http://www.gtkforums.com/viewtopic.php?f=988&p=195276=Styling+a+GtkTextView+with+Gtk3+and+Css%3A#p195276
这可能就是您正在寻找的内容: http:// developer.gnome.org/gtk3/3.0/GtkWidget.html#gtk-widget-override-cursor
This is probably what you are looking for: http://developer.gnome.org/gtk3/3.0/GtkWidget.html#gtk-widget-override-cursor
实际上,似乎有光标颜色样式属性:
http://developer.gnome.org/gtk3/ 3.0/GtkWidget.html#GtkWidget--s-cursor-color
Actually, there seem to be cursor-color style property:
http://developer.gnome.org/gtk3/3.0/GtkWidget.html#GtkWidget--s-cursor-color