Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3666676
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:54:34+00:00 2026-05-19T01:54:34+00:00

Hopefully this is an easy question to answer! I am trying to use GtkEntryCompletion

  • 0

Hopefully this is an easy question to answer! I am trying to use GtkEntryCompletion (a la the example here) but while this code works I can’t seem to get the GtkEntry to present the autocomplete results when I set the text of the field programatically. What I am trying to accomplish is a semi pre-filled text entry that is already presenting the user with some autocomplete options.

To set the text I have tried using the functions gtk_entry_set_text(…), gtk_entry_buffer_insert_text(…) and even gtk_entry_buffer_emit_inserted_text(…) but to no avail. Is there a way to do this in such a way as to act like regular user input and display the suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:54:34+00:00Added an answer on May 19, 2026 at 1:54 am

    I think you need to call gtk_entry_completion_complete after setting the text.

    EDIT

    Sorry @Tylter, but wow, this is way more difficult than I imagined. The only way I can figure out how to do it is to actually send the keypress event to the window.

      gtk_widget_grab_focus(entry);
    
      GdkEvent new_event;
      new_event.key.type = GDK_KEY_PRESS;
      new_event.key.window = gtk_widget_get_parent_window(entry);
      new_event.key.send_event = TRUE;
      new_event.key.time = GDK_CURRENT_TIME;
      new_event.key.keyval = 0x053; // capital S
      new_event.key.state = GDK_KEY_PRESS_MASK;
      new_event.key.length = 0;
      new_event.key.string = 0;
      new_event.key.hardware_keycode = 0;
      new_event.key.group = 0;
    
      gdk_event_put((gpointer)&new_event);
    

    EDIT 2

    Are you using a GtkDialog for your pop-up? I coded this up really quick and it seems to work. Here you would be creating the dialog in a button click event:

    static void click_event( GtkWidget *widget,
                         gpointer   data )
    {
       GtkWidget* window = gtk_dialog_new ();
       completion = create_completion();
       entry = gtk_entry_new();
       gtk_entry_set_completion(GTK_ENTRY(entry), completion);
       // add entry to dialog
       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area),
                            entry, TRUE, TRUE, 0);
    
       gtk_widget_show(entry);    
       gtk_widget_show(window);  // you must show the window before sending the keypress event
    
       gtk_widget_grab_focus(entry);
    
       GdkEvent new_event;
       new_event.key.type = GDK_KEY_PRESS;
       new_event.key.window = gtk_widget_get_parent_window(entry);
       new_event.key.send_event = TRUE;
       new_event.key.time = GDK_CURRENT_TIME;
       new_event.key.keyval = 0x053; // capital S
       new_event.key.state = GDK_KEY_PRESS_MASK;
       new_event.key.length = 0;
       new_event.key.string = 0;
       new_event.key.hardware_keycode = 0;
       new_event.key.group = 0;
    
       gdk_event_put((gpointer)&new_event);
    
    }
    

    The only gotcha I saw with this is that your must show the dialog window before sending the keypress event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hopefully an easy question, but I'd quite like a technical answer to this! What's
Hopefully this is a simple one, but can anyone provide some simple c# code
Hopefully, this will be an easy answer for someone with Javascript time behind them...
I'm new to jQuery so hopefully there is an easy answer to this. I
This will hopefully be an easy one. I have an F# project (latest F#
Another easy one hopefully. Let's say I have a collection like this: List<DateTime> allDates;
Hopefully this will not spark a religious war... We have a web based app
Hopefully this still falls within StackOverflow's umbrella! I'm looking to create a quick boot
Hopefully this is a really quick one ;) I have written a lexer /
This should hopefully be a simple one. I would like to add an extension

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.