Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » GLCtrl don't have Key() method wokring
GLCtrl don't have Key() method wokring [message #52870] Fri, 20 December 2019 20:50 Go to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello community,

I know it's probably not a bug and it work as intended but the overwrite of virtual key method on GlCtrl inheriteds class don't work !
Instead, to manage keytboard input event on the GLCtrl I need to install keyhook like that :
{
 //Constructor of my GlCtrl inherited class
	InstallKeyHook(&OpenGLExample::CtrlKeyHook); //Activate KeyEvent

}

//Static method of my class
static bool CtrlKeyHook(Ctrl* ctrl, dword key, int count)
	LOG("A key have been pressed !");
	return true;
}


But, since all mouse event can be properly overwritten in GLCtrl inherited class, why those key method can't be ?

Thanks in advance

Xemuth

[Updated on: Fri, 20 December 2019 20:56]

Report message to a moderator

Re: GLCtrl don't have Key() method wokring [message #52924 is a reply to message #52870] Mon, 13 January 2020 15:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Xemuth wrote on Fri, 20 December 2019 20:50
Hello community,

I know it's probably not a bug and it work as intended but the overwrite of virtual key method on GlCtrl inheriteds class don't work !
Instead, to manage keytboard input event on the GLCtrl I need to install keyhook like that :
{
 //Constructor of my GlCtrl inherited class
	InstallKeyHook(&OpenGLExample::CtrlKeyHook); //Activate KeyEvent

}

//Static method of my class
static bool CtrlKeyHook(Ctrl* ctrl, dword key, int count)
	LOG("A key have been pressed !");
	return true;
}


But, since all mouse event can be properly overwritten in GLCtrl inherited class, why those key method can't be ?

Thanks in advance

Xemuth


Does it have a focus?

Mirek
Re: GLCtrl don't have Key() method wokring [message #52934 is a reply to message #52924] Tue, 14 January 2020 14:29 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello Mirek,

In my opinion yes since all MouseMove is triggered.
To try it from your side, open "OpenGL" exemple in reference and add this method in OpenGLExample class :
	virtual bool Key(dword key, int count) override{
		Cout() << "Key Pressed !" << EOL;
		return false;
	}

you will see it wont work.

Xemuth
Re: GLCtrl don't have Key() method wokring [message #52959 is a reply to message #52934] Tue, 21 January 2020 14:41 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Xemuth wrote on Tue, 14 January 2020 14:29
Hello Mirek,

In my opinion yes since all MouseMove is triggered.
To try it from your side, open "OpenGL" exemple in reference and add this method in OpenGLExample class :
	virtual bool Key(dword key, int count) override{
		Cout() << "Key Pressed !" << EOL;
		return false;
	}

you will see it wont work.

Xemuth


Because it does not have focus. Try

GUI_APP_MAIN
{
	Ctrl::GlobalBackPaint();
	TopWindow win;
	OpenGLExample gl;
	gl.SetFrame(InsetFrame());
	win.Add(gl.HSizePos(10, 10).VSizePos(10, 10));
	win.Sizeable().Zoomable();
	win.ActiveFocus(gl);
	win.Open();
	win.Run();
}

Re: GLCtrl don't have Key() method wokring [message #52980 is a reply to message #52870] Tue, 28 January 2020 11:45 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Thanks Mirek for having solve my problem,

Another quick question, if the Ctrl didn't had focus before, why mouse event where working fine ? Isn't Mouseevent supposed to require focus ?

Thanks in advance,
Best Regard.

Xemuth
Re: GLCtrl don't have Key() method wokring [message #52981 is a reply to message #52980] Tue, 28 January 2020 12:37 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Xemuth wrote on Tue, 28 January 2020 11:45
Thanks Mirek for having solve my problem,

Another quick question, if the Ctrl didn't had focus before, why mouse event where working fine ? Isn't Mouseevent supposed to require focus ?

Thanks in advance,
Best Regard.

Xemuth


No, focus is just for keyboard.

BTW, things were a little bit complicated, the real reason why your code was not working outright was NoWantFocus flag in GLCtrl. That prevented TopWindow to assign focus to it on open. I had decided to remove this flag, so your original code would work as is.
Re: GLCtrl don't have Key() method wokring [message #52983 is a reply to message #52981] Tue, 28 January 2020 16:50 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Ok Thanks Mirek, have a good day
Previous Topic: [SOLVED] Dual GlCtrl in one frame ?
Next Topic: [SOLVED]Removing glaux lib from GLctrl
Goto Forum:
  


Current Time: Thu Mar 28 10:06:22 CET 2024

Total time taken to generate the page: 0.01211 seconds