HotKey for every controls

Creative ideas/suggestions for HMG

Moderator: Rathinagiri

User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

HotKey for every controls

Post 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? )
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HotKey for every controls

Post 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 :)
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HotKey for every controls

Post 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.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HotKey for every controls

Post 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..
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: HotKey for every controls

Post 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
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HotKey for every controls

Post 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?)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HotKey for every controls

Post 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.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HotKey for every controls

Post by mol »

It's also interesting and more universal :)
Great!
regards, Marek
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HotKey for every controls

Post 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
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HotKey for every controls

Post by Rathinagiri »

How about using Claudio Soto's Readkey?

http://hmgforum.com/viewtopic.php?f=15&t=1331
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply