Results 1 to 3 of 3

Thread: func_input callbacks not working

  1. #1
    Lesser Knight
    Join Date
    Sep 2006
    Location
    Barcelona, Catalonia
    Posts
    30

    Default func_input callbacks not working

    Hi, I'm trying to get "func_*" callbacks of CL_GUIComponent working, but I fear that there exist some kind of bug...while callbacks_0 like 'pointer_enter' are invoked, callbacks_1 like 'input_released" are not. In fact, checking if they are null I receive a true as an answer, when they were correctly linked to a method of my class.

    Writing some clean code to check these problems, I created a class that used one callback of each type, with this header:

    Code:
    #ifndef __ScriptButton_hxx__
    #define __ScriptButton_hxx__
    
    #include <ClanLib/core.h>
    #include <ClanLib/display.h>
    #include <ClanLib/gui.h>
    
    class ScriptButton : public CL_GUIComponent
    {
    	CL_Font_System * _font;
    public:
    	ScriptButton(CL_GUIComponent *parent);
    	virtual ~ScriptButton();
    
    	void on_render(CL_GraphicContext &gc, const CL_Rect &cliprect);
    	bool onPointerEnter();
    	bool onInputReleased(const CL_InputEvent &inputEvent);
    	void onProcessMessage(CL_GUIMessage & message);
    };
    
    #endif // __ScriptButton_hxx__
    and the definition:

    Code:
    #include "ScriptButton.hxx"
    
    ScriptButton::ScriptButton( CL_GUIComponent *parent) : CL_GUIComponent(parent), _font(0)
    {
    	set_constant_repaint(true);
    
    	func_render().set(this, &ScriptButton::on_render);
    	func_pointer_enter().set(this, &ScriptButton::onPointerEnter);
    	func_input_released().set(this, &ScriptButton::onInputReleased);
    	func_process_message().set(this, &ScriptButton::onProcessMessage);
    
    	CL_FontDescription fontDesc;
    	fontDesc.set_typeface_name("tahoma");
    	_font = new CL_Font_System(get_gc(), fontDesc);
    	set_geometry(CL_Rect(0,0,CL_Size(500,500)));
    }
    
    ScriptButton::~ScriptButton()
    {
    	delete _font;
    }
    
    bool ScriptButton::onPointerEnter()
    {
    	std::cout << "pointer enter" << std::endl;
    	return true;
    }
    
    void ScriptButton::on_render(CL_GraphicContext &gc, const CL_Rect &cliprect)
    {
    	_font->draw_text(gc,200,300,"Hello World");
    }
    
    bool ScriptButton::onInputReleased(const CL_InputEvent & inputEvent)
    {
    	std::cout << "input released" << std::endl;
    	return true;
    }
    
    void ScriptButton::onProcessMessage(CL_GUIMessage & message)
    {
    	if (message.is_type(CL_GUIMessage_Input::get_type_name()))
    	{
    		CL_GUIMessage_Input input = message;
    		CL_InputEvent input_event = input.get_event();
    		if (input_event.type == CL_InputEvent::released && input_event.id == CL_MOUSE_LEFT)
    		{
    			std::cout << "process message input released" << std::endl;
    			if (this->func_input_released().is_null())
    			{
    				std::cout << "func input released null" << std::endl;
    			}
    			if (this->func_pointer_enter().is_null())
    			{
    				std::cout << "func pointer enter null" << std::endl;
    			}
    		}
    	}
    }
    The result of executing the app and clicking inside this component is:
    Code:
    pointer enter
    process message input released
    func input released null
    Any idea ? I'm trying to check the callback_1 code now to see if there exist some problem with it...

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    This is a bug - it has been fixed in the latest svn version of 2.0.

    (It was caused by the callbacks not being returned by reference)

  3. #3
    Lesser Knight
    Join Date
    Sep 2006
    Location
    Barcelona, Catalonia
    Posts
    30

    Default

    Thanks Magnus, I'm checking out the repository instead of working with the last stable release.

Similar Threads

  1. Working with Linux
    By Ciperl in forum Other RTsoft Games
    Replies: 3
    Last Post: 04-17-2013, 09:58 AM
  2. an idea of callbacks mudule
    By jiao in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 07-19-2009, 04:18 PM
  3. What are you working on?
    By whisperstorm in forum Novashell Game Creation System
    Replies: 8
    Last Post: 06-19-2007, 03:52 PM
  4. I can't get funeral quest working over my firewall
    By rmcnew in forum Funeral Quest
    Replies: 4
    Last Post: 01-12-2004, 07:16 AM
  5. I could not get it working
    By in forum Other RTsoft Games
    Replies: 5
    Last Post: 06-03-2003, 06:13 AM

Bookmarks

Bookmarks

Posting Permissions

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