Results 1 to 3 of 3

Thread: Two questions regarding user input (callback functions)

  1. #1

    Default Two questions regarding user input (callback functions)

    Hi all, I have two questions regarding user input:

    My main program class "Program" contains a static method
    static void keyboardInput(const CL_InputEvent &event, const CL_InputState &state);
    In the main method I then do the following:
    CL_InputDevice keyboard = window.get_ic().get_keyboard();
    And the method itself looks like this:
    void Program::keyboardInput(const CL_InputEvent &event, const CL_InputState &state)
    	if( == CL_KEY_ESCAPE)
    		shutdown = true;
    Unfortunately this does not work, the static method is never called when a key is pressed.
    What do I wrong here?

    By now I poll mouse button clicks (no callback as above, that works). I want to exit the app when the user clicks the window's X (i.e. close) button in the top-right corner -- as any other window as well under MS Windows. However, when I click on the X button at my ClanLib window, nothing happens. How can I achieve to close the app when the user clicks on X?

    Thanks in advance!

    Kind regards, Matthias

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Bergen, Norway


    Whenever hooking up a CL_Signal, you need to keep the CL_Slot around:

    slot_input = keyboard.sig_key_down().connect(&Program::keyboard Input);

    (and define CL_Slot slot_input somewhere it doesn't go out of scope).


    If you want to close the window when the user presses the X, you need to hook up CL_DisplayWindow sig_window_close:

    CL_Slot slot_quit = window.sig_window_close().connect(this, &MyClass:n_window_close);

    Check out almost any example in the Examples directory for similar stuff.

  3. #3


    thank you!

Similar Threads

  1. First-time user, Novashell launches without any text?
    By MrBagel in forum Novashell Game Creation System
    Replies: 14
    Last Post: 10-24-2011, 04:59 AM
  2. Questions from new user
    By Ogga in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 11-30-2009, 07:52 AM
  3. Request for linux expert to check a couple of functions
    By rombust in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 10-13-2009, 03:20 PM
  4. New User Crashing Game
    By File Sponge in forum Funeral Quest
    Replies: 1
    Last Post: 04-07-2007, 12:00 AM
  5. Dink On XP User accounts
    By xylix in forum Dink Smallwood HD
    Replies: 0
    Last Post: 02-11-2005, 08:47 AM



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts