Page 1 of 2

HotKey for every controls

Posted: Fri Apr 16, 2010 7:02 am
by mol
I'm building application for billing. I prefer keyboard.
So my idea is:
ability to define hotkey for every control

Now, we can realise that by ON KEY..., but it requests coding.

Best regards, Marek


(ps. It should be easy to do, I think.... :D, and, what do you, Roberto, think? )

Re: HotKey for every controls

Posted: Fri Apr 16, 2010 1:25 pm
by Roberto Lopez
mol wrote:I'm building application for billing. I prefer keyboard.
So my idea is:
ability to define hotkey for every control

Now, we can realise that by ON KEY..., but it requests coding.

Best regards, Marek


(ps. It should be easy to do, I think.... :D, and, what do you, Roberto, think? )
It's a nice idea, but no so much easy to make :)

Re: HotKey for every controls

Posted: Fri Apr 16, 2010 3:29 pm
by mol
This idea circulates in my head.
I'll realize in my app. declaring table for each window eg. { HotKey, cControlName}
then with _DefineHotKey I'll define hotkeys.

Re: HotKey for every controls

Posted: Fri Apr 16, 2010 7:27 pm
by mol
I've prepared a little sample with hotkeys

Code: Select all


#include "hmg.ch"

/* Hotkeys for selected controls sample	*/
/* Marek Olszewski, MOL-SK 2010.04.16	*/

Function Main
Local bBlock

	DEFINE WINDOW Win_1 ;
		AT 0,0 ;
		WIDTH 400 ;
		HEIGHT 400 ;
		TITLE 'HotKey Demo' ;
		MAIN  

		@ 10,50 label lt1 ;
			value "Press Ctrl-1 to activate TextBox1" ;
			width 200
		@ 40,50 TEXTBOX Text_1 ;
			VALUE 123 ;
			WIDTH 120;
			TOOLTIP 'Numeric TextBox' ;
			NUMERIC ;
			MAXLENGTH 5 
		@ 70,50 label lt2 ;
			value "Press Ctrl-2 to activate TextBox2" ;
			width 200
		@ 100,50 TEXTBOX Text_2 ;
			VALUE 123 ;
			WIDTH 120;
			TOOLTIP 'Numeric TextBox' ;
			NUMERIC ;
			MAXLENGTH 5 
		@ 130,50 label lt3 ;
			value "Press Ctrl-3 to activate TextBox3" ;
			width 200
		@ 160,50 TEXTBOX Text_3 ;
			VALUE 123 ;
			WIDTH 120;
			TOOLTIP 'Numeric TextBox' ;
			NUMERIC ;
			MAXLENGTH 5 
		

	END WINDOW
	ahotkeys := {{VK_1, "Text_1"}, {VK_2, "Text_2"}, {VK_3, "Text_3"}}
	for i := 1 to len(aHotKeys)
		bBlock := '{|| DoMethod("WIN_1","'+aHotKeys[ i,2]+ '","SetFocus")}'
		_DefineHotKey ( "WIN_1" , MOD_CONTROL , aHotKeys[i,1] , &bBlock)
	next i
	
	CENTER WINDOW Win_1
	ACTIVATE WINDOW Win_1

Return
You can find Keycodes in hmg/include/i_keybd.ch

to do:
I don't know how to paste block to function without executing it..

Re: HotKey for every controls

Posted: Fri Apr 16, 2010 8:32 pm
by esgici
mol wrote:... I prefer keyboard.
...
ability to define hotkey for every control
...
Hi All

I fully share Marek's opinion.

I can't forget INKEY() yet :(

Regards, saludos

--

Esgici

Re: HotKey for every controls

Posted: Sat Apr 17, 2010 5:52 am
by mol
Roberto Lopez wrote: It's a nice idea, but no so much easy to make :)

Going this way, I think it's very easy to make.
One extra field in IDE Object inspector (of course, it should be added to definition of every control), and while processing every control, added phrase
if !empty(HotKey)
_defineHotkey(....)
endif

It could be done without controlling syntactic correctness, with programmers responsibility.


(ps. Maybe for textboxes, datepicters for now?)

Re: HotKey for every controls

Posted: Sat Apr 17, 2010 12:44 pm
by Roberto Lopez
mol wrote:
Roberto Lopez wrote: It's a nice idea, but no so much easy to make :)

Going this way, I think it's very easy to make.
One extra field in IDE Object inspector (of course, it should be added to definition of every control), and while processing every control, added phrase
if !empty(HotKey)
_defineHotkey(....)
endif

It could be done without controlling syntactic correctness, with programmers responsibility.


(ps. Maybe for textboxes, datepicters for now?)
I must think about it and test various solutions, but, my first idea is a 'OnKey' event for controls.

This event should receive the pressed keycode.

Re: HotKey for every controls

Posted: Sat Apr 17, 2010 1:32 pm
by mol
It's also interesting and more universal :)
Great!
regards, Marek

Re: HotKey for every controls

Posted: Sat Apr 17, 2010 6:21 pm
by mol
I thought about OnKey event and in my opinion, this won't be the same as Hotkey.
Onkey will be fired after key pressed - but control will be focused yet.

Hotkey should be quick implementation of ON KEY of WindowName.... phrase.

Marek

Re: HotKey for every controls

Posted: Mon Apr 19, 2010 6:05 am
by Rathinagiri
How about using Claudio Soto's Readkey?

http://hmgforum.com/viewtopic.php?f=15&t=1331