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

  • SEARCH
  • Home
  • 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 8168883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:40:15+00:00 2026-06-06T20:40:15+00:00

Ths is my problem : I am trying to add keyboard control to my

  • 0

Ths is my problem :

I am trying to add keyboard control to my application using a dictionary of (string,VoidFunc)

I start by creationg an action named “app.” + key_name(“h” for example) and doing

action.activate.connect( () => f() ) where f is the function (VoidFunc instance).

Then I add that action to my app.

Then I create an accelerator using Gtk.accelerator_name and add that to my app.

I am subclassing Gtk.Application.

Here are the two main functions that do the work.

private void install_keyboard_support()
{
    Gee.HashMap<string,VoidFunc> actions = new Gee.HashMap<string,VoidFunc>();
    fill_actions(ref actions);
    int i = 0;int sz = actions.size;
    while(i < sz)
    {
        string k = actions.keys.to_array()[i];
        var f = actions[k];
        var action_name = "app." + k;

        var action = new SimpleAction(action_name,null);
        action.activate.connect(() => f());
        this.add_action(action);

        var accel_name = Gtk.accelerator_name(k.data[0],Gdk.ModifierType.CONTROL_MASK);
        this.add_accelerator(accel_name,action_name,null);

        _puts(@"Added accelerator with name = $accel_name and which trigers $action_name action!");

        i++;
    }

    _puts("Installed keyboard support!");
}

private void fill_actions(ref Gee.HashMap<string,VoidFunc> actions)
{
    actions["h"] = () => Process.spawn_command_line_async("xdg-open /usr/share/doc/ewns-viewer/help.html");
}

As you see everything should work :).

One thing that works is doing

this.add_accelerator("<Primary>h","app.help",null)

app.help is a simple action definied as

var help_action = new SimpleAction("help",null);
    help_action.activate.connect(() => Process.spawn_command_line_async("xdg-open /usr/share/doc/ewns-viewer/help.html"));
    this.add_action(help_action);
  • 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-06-06T20:40:17+00:00Added an answer on June 6, 2026 at 8:40 pm

    The problem was that I created actions with “app.” + k while the app. prefix was not needed.

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

Sidebar

Related Questions

my application sends file to server using (socket tcp c#) the file transfer works
I am a Perl newbie, and i'm stuck with ths problem: I have a
I have this code: public static Account[] LoadXml(string fileName) { Account ths = new
I've looked everywhere and tried a lot of fixes to solve ths problem but
I create simple slider accordion ans it´s my code , ths only problem it´s
I have run security check on my application, and got the following warning: 'Parser.GenerateJeffpReport(string)'
I have ths line in my .vimrc: map gu :%s/\s\+$//<enter> :w<enter> to remove trailing
suppose I have a model and a view ,ths view have two method:one is
I want to get a list of all TRs that do not include THs.
I am using below code to generate word document using assp.net/c#.net, please tell me

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.