简体   繁体   中英

How to remove caret cursor in Gtk entry

I have a Gtk entry. I need to completely remove this caret cursor, how can I do this? I searched for information about this for a long time but found only how to remove the blinking of Gtk entry.

Until you find a better one use CSS.

Just set the caret-color background to the same background-color of the entry :

main.c

#include <gtk/gtk.h>

int main ( void )
{
    GtkWidget *window;
    GtkWidget *grid;
    GtkWidget *entry;

    /// ***
    gtk_init ( NULL, NULL );

    /// ***
    window = gtk_window_new ( GTK_WINDOW_TOPLEVEL );
    gtk_window_set_title ( GTK_WINDOW ( window ), "Hello There!" );
    gtk_window_set_default_size ( GTK_WINDOW ( window ), 200, 100 );
    g_signal_connect ( window, "destroy", gtk_main_quit, NULL );

    ///***
    grid = gtk_grid_new();
    gtk_container_add ( GTK_CONTAINER ( window ), grid );

    ///***
    entry = gtk_entry_new();
    g_object_set ( entry, "margin-top", 30, NULL );
    g_object_set ( entry, "margin-left", 20, NULL );
    gtk_grid_attach ( GTK_GRID ( grid ), entry, 0, 0, 1, 1 );

    /// ***
    gtk_widget_show_all ( window );
    gtk_main();
}

CSS:

window
{
    background-color: red;
}

entry
{
    background-color: yellow;
    caret-color:      yellow;
}

rezult: 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM