Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Invisible buttons hot key
Message
De
23/10/2008 13:30:06
 
 
À
23/10/2008 03:35:50
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01356027
Message ID:
01356654
Vues:
37
Hi Agnes,
Yes.. the idea with BindEvents() is quite good.. I thinking it will work.
I just thinking.. how many buttons will listen the same keypress event.. 20... 50.. each keypress willl fair catch_keypress in 50 buttons.. every button will check if its the keycode whats neccessary...... hmmm..
Now.. lets think.. user type text in Editbox.. what will happens in system.. each key press will far 50 events.. where 50 methods will check hot keys..What's happens with performance?
and for example.. our application using Pageframe as host for containers.. sometimes its 27 pages.. each 27 pages has buttons.. maybe.(maybe) on page 1.. exist button with hot key "S"... and on page10 also.. and on page12 also..
Can you imagine whats heppens then?! :))))

The code what I writing - its a code for restyle existing application.. just lifting of interface, make it more modern and beauty..
So far.. I thinking.. your solution will works.. but.. but past of this solution might be on my look more horrible then advantage :)))

Denis


>>Hi Craig,
>>Thats trick.. I made Office2007 buttons style (using container and styled pictures for background). The button looks 100% same as Office product has, but the problem - I need to use navigation keys to set focus on the button or Hot keys.
>
>This is your fault ::)
>
>>So, for this reason, I put into container button with Button.Style=1 - now navigation with arrow or Tab works perfect.. and also, I have selection rectangle.. so.. all features there!
>>User can see a Label caption what I put into container before - and invisible button works as background object for selection.
>>
>>Now problem only in Hot Keys
>
>Let me explain again:
>1)
>Set Form.KeyPreview = .T.
>
>So the form catches Keystrokes first
>
>2)
>Add your buttons (it is a class isn't it?) a Property "gaKeys(36,2)"
>
>3)
>in Buttons Init
>*Inkey codes
>WITH THIS
> .gaKeys(01,1) = '1'
> .gaKeys(01,2) = 120
> .gaKeys(02,1) = '2'
> .gaKeys(02,2) = 121
> .gaKeys(03,1) = '3'
> .gaKeys(03,2) = 122
> .gaKeys(04,1) = '4'
> .gaKeys(04,2) = 123
> .gaKeys(05,1) = '5'
> .gaKeys(05,2) = 124
> .gaKeys(06,1) = '6'
> .gaKeys(06,2) = 125
> .gaKeys(07,1) = '7'
> .gaKeys(07,2) = 126
> .gaKeys(08,1) = '8'
> .gaKeys(08,2) = 127
> .gaKeys(09,1) = '9'
> .gaKeys(09,2) = 128
> .gaKeys(10,1) = '0'
> .gaKeys(10,2) = 19
> .gaKeys(11,1) = 'a'
> .gaKeys(11,2) = 30
> .gaKeys(12,1) = 'b'
> .gaKeys(12,2) = 48
> .gaKeys(13,1) = 'c'
> .gaKeys(13,2) = 46
> .gaKeys(14,1) = 'd'
> .gaKeys(14,2) = 32
> .gaKeys(15,1) = 'e'
> .gaKeys(15,2) = 18
> .gaKeys(16,1) = 'f'
> .gaKeys(16,2) = 33
> .gaKeys(17,1) = 'g'
> .gaKeys(17,2) = 34
> .gaKeys(18,1) = 'h'
> .gaKeys(18,2) = 35
> .gaKeys(19,1) = 'I'
> .gaKeys(19,2) = 23
> .gaKeys(20,1) = 'j'
> .gaKeys(20,2) = 36
> .gaKeys(21,1) = 'k'
> .gaKeys(21,2) = 37
> .gaKeys(22,1) = 'l'
> .gaKeys(22,2) = 38
> .gaKeys(23,1) = 'm'
> .gaKeys(23,2) = 50
> .gaKeys(24,1) = 'n'
> .gaKeys(24,2) = 49
> .gaKeys(25,1) = 'o'
> .gaKeys(25,2) = 24
> .gaKeys(26,1) = 'p'
> .gaKeys(26,2) = 25
> .gaKeys(27,1) = 'q'
> .gaKeys(27,2) = 16
> .gaKeys(28,1) = 'r'
> .gaKeys(28,2) = 19
> .gaKeys(29,1) = 's'
> .gaKeys(29,2) = 31
> .gaKeys(30,1) = 't'
> .gaKeys(30,2) = 20
> .gaKeys(31,1) = 'u'
> .gaKeys(31,2) = 22
> .gaKeys(32,1) = 'v'
> .gaKeys(32,2) = 47
> .gaKeys(33,1) = 'w'
> .gaKeys(33,2) = 17
> .gaKeys(34,1) = 'x'
> .gaKeys(34,2) = 45
> .gaKeys(35,1) = 'y'
> .gaKeys(35,2) = 21
> .gaKeys(36,1) = 'z'
> .gaKeys(36,2) = 44
>ENDWITH &&THIS
>
>
>
>4)
> Add your buttons (it is a class isn't it?) a Method "CatchKey_Event"
>
>LPARAMETERS tnKeyCode, tnShiftAltCtrl
>
>LOCAL;
> lnPos,;
> lcKey
>
>lnPos = AT('\<',THIS.CAPTION)
>IF lnPos>0 AND tnShiftAltCtrl=4 THEN
> lcKey = LOWER(SUBSTR(THIS.CAPTION,lnPos+2,1))
>
> lnPos = ASCAN(THIS.gaKeys,lcKey,1,-1,1,8)
> IF lnPos >0 AND tnKeyCode=THIS.gaKeys(lnPos ,2) THEN
>  RAISEEVENT(THIS,'Click')
> ENDIF &&lnPos >0 AND tnKeyCode=THIS.gaKeys(lnPos ,2)
>ENDIF &&lnPos>0 AND tnShiftAltCtrl=4
>
>
>5)
>Somewhere in forms init, BINDEVENT(THIS,'KEYPRESS',RefToYourButton,'CatchKey_Event')
>
>This will catch the key and raise the click event
>
>There is one problem with this. If you assign the same key to more then one button, it will raise the events of all buttons with the same key. VFP nativ is only the first one.
>
>Code is untested and without any errorhandling
>Agnes
>
>>>If the button is invisible, how is the user going to know they can press Alt+S?
>>>
>>>>Hi,
>>>>Is there a way to make invisible buttons behaviour like standard buttons for hot keys?
>>>>For example, when I have a
button.caption = "\<Search"
- then Hot key is ALT+S.
>>>>In case with vfp standard button - when I press ALT+S - its automatically starts CLCK() event.
>>>>In case with invisible button - its just set focus to the button and raise no click event.
>>>>
>>>>Any ideas,
>>>>Thanks
>>>>Denis
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform