"SET NAVIGATION EXTENDED" in HMG.4

Moderator: Rathinagiri

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: "SET NAVIGATION EXTENDED" in HMG.4

Post by l3whmg »

Hi friends.
A little brief about SET NAVIGATION... with HMG3: when active, you can use ENTER like TAB to move from an "object to another object". Not everywere, please remember about EDITBOX....

About previous textbox, but not only this object: the ENTER like TAB not was inplemented very well. You can use ENTER but not everywhere you can jump from another to another field....What I mean is: not was implemented yet very well. It can be (probably) implemented or improved.

About arrows up and down: I think we must rewrite Qt behaviour or intercept everywhere key pressed! I think there are few GUI manager that use this. Everyone can try to understand how to change current HMG to manage this.

Cheers.
Luigi from Italy
www.L3W.it
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: "SET NAVIGATION EXTENDED" in HMG.4

Post by mrduck »

l3whmg wrote: I think we must rewrite Qt behaviour or intercept everywhere key pressed! I think there are few GUI manager that use this. Everyone can try to understand how to change current HMG to manage this.
In control.prg there is ProcessKeyPressed. We just need to call it... Well, not "just", we have to adapt it...


Ciao
Rossine
Posts: 87
Joined: Thu Jun 30, 2011 10:04 pm

Re: "SET NAVIGATION EXTENDED" in HMG.4

Post by Rossine »

Hello All,

In hmg.3 I use to do this "gotfocus / lostfocus" (I know this is not the right solution, but I only had she)

Look for certain objects that "richedit/combobox/btntextbox" I define set to up / down and combobox list is open when I turn off the arrows so you can navigate the combobox and so the list is closed arrows work again for change of focus.

Code: Select all


Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'Harbour MiniGUI Demo' ;
		ICON 'DEMO.ICO' ;
		MAIN ;
		FONT 'Arial' SIZE 10

		@ 30,10 TEXTBOX Texbox_1 ;
			WIDTH 410 ;
			HEIGHT 140 ;
			VALUE  cVar

    SET_PROPERTY( "cWnd", "Texbox_1" )

	END WINDOW

	Form_1.Center()

	Form_1.Activate()

Return Nil

function SET_PROPERTY( cWnd, cObj )

* HERE DEFINE GOTFOCUS

   bBlock := '{ || '

   if     upper(alltrim(left(cObj,5))) == "RICHE" .or. upper(alltrim(left(cObj,4))) $ [LIST,TREE]
          bBlock += ' ( _ReleaseHotKey( "' + cWnd + '", 0, 40 ), _ReleaseHotKey( "' + cWnd + '", 0, 38 ) )'
   elseif upper(alltrim(left(cObj,5))) == "COMBO"
          bBlock += ' ( _DefineHotKey( "' + cWnd + '", 0 , 40 , { || InsertTab() } ), _DefineHotKey( "' + cWnd + '", 0 , 38 , { || InsertShiftTab()} ) )'
   elseif upper(alltrim(left(cObj,5))) $ [TEXT_,GETBO,BTNTE]
          bBlock += ' ( _DefineHotKey( "' + cWnd + '", 0 , 13, { || InsertTab() } ) )'
   endif
   bBlock  += ' ) }'
   bBlock  := &( bBlock )
   SET_PROP( "GOTFOCUS", cWnd, cObj, bBlock )

* HERE DEFINE LOSTFOCUS

   bBlock  := '{ || MYLOSTFOCUS( "' + cWnd + '", "' + cObj + '",'

   if     upper(alltrim(left(cObj,5))) == "RICHE" .or. upper(alltrim(left(cObj,4))) $ [LIST,TREE]
          bBlock += ', { || ( _DefineHotKey( "' + cWnd + '", 0 , 40 , { || InsertTab() } ), _DefineHotKey( "' + cWnd + '", 0 , 38 , { || InsertShiftTab() } ) ) }'
   elseif upper(alltrim(left(cObj,5))) $ [TEXT_,GETBO,BTNTE,COMBO]
          bBlock += ', { || ( _ReleaseHotKey( "' + cWnd + '", 0, 13 ) ) }'
   elseif upper(alltrim(left(cObj,4))) == "LIST"
          bBlock += ', { || ( _ReleaseHotKey( "' + cWnd + '", 0, 13 ) ) }'
   endif
   bBlock  += ' ) }'

   bBlock  := &( bBlock )
   SET_PROP( "LOSTFOCUS", cWnd, cObj, bBlock )

   if upper(alltrim(left(cObj,5))) == "COMBO"
      bBlock := &( '{ || ( _ReleaseHotKey( "' + cWnd + '", 0, 40 ), _ReleaseHotKey( "' + cWnd + '", 0, 38 ) ) }' )
      SET_PROP( "COMBOOPENITENS", cWnd, cObj, bBlock )
      bBlock := &( '{ || ( _DefineHotKey( "' + cWnd + '", 0 , 40 , { || InsertTab() } ), _DefineHotKey( "' + cWnd + '", 0 , 38 , { || InsertShiftTab() } ) ) }' )
      SET_PROP( "COMBOCLOSEITENS", cWnd, cObj, bBlock )
   endif
endif

return NIL

I also think the best solution to treat it in the process of keystrokes

Best Regards,

Rossine.

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: "SET NAVIGATION EXTENDED" in HMG.4

Post by l3whmg »

Hi to everyone.
@MrDuck
I know there is this method (I write it on 2011-07-04), but as you write we must revised it. I wrote this method specifically to handle the event OnEnter (not only), but when I did not yet have a good knowledge of the QT events (also today I must understand a lot of QT). In addition, it could create conflicts with events that are now used (do you remember "hot to have more then one event handling?"). Anyway, I think you are right: we must investigate and improve it.

@Rossine
I must understand your code :) I think we must leave QT do the work and we must use its events and signals.
Luigi from Italy
www.L3W.it
Rossine
Posts: 87
Joined: Thu Jun 30, 2011 10:04 pm

Re: "SET NAVIGATION EXTENDED" in HMG.4

Post by Rossine »

Hello Luigi,

It would be interesting if the user could navigate through the fields using ENTER / DOWN ARROW / UP because so users do not need to use the mouse. I know hmg.4/QT set to run with QT is not easy because I tried and could not move because I lack knowledge. I'll try to better understand hmg.4 involved manipulating the keyboard and see if I can build something here.

Thanks for any help,

Rossine.
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: "SET NAVIGATION EXTENDED" in HMG.4

Post by l3whmg »

Hi Rossine.
Yes I know it is "difficult" and I think you can start with current method ProcessKeyPressed to understand event/slot and try to find a solution and test it with a simple form with 2/3 textbox and one button......

Cheers
Luigi from Italy
www.L3W.it
Rossine
Posts: 87
Joined: Thu Jun 30, 2011 10:04 pm

Re: "SET NAVIGATION EXTENDED" in HMG.4

Post by Rossine »

Hi Luigi,

Yes, I will do this and reports the results ;)

Best Regards,

Rossine.
Rossine
Posts: 87
Joined: Thu Jun 30, 2011 10:04 pm

Re: "SET NAVIGATION EXTENDED" in HMG.4

Post by Rossine »

Hello,

Now "Textbox" work´s with arrows UP and DOWN. See this piece of code: (textbox.prg)

Code: Select all

..............................................................................*/
METHOD __HmgProcessKey( oQtEvent ) CLASS TEXTBOX

   LOCAL lQtEventStop   := .F.      // .F. means don't stop event hanlder, else .T. STOP see Harbour Changelog
   LOCAL cChar := oQtEvent:text()
   LOCAL nKey := oQtEvent:key()

   // must be improved eg ALT+0126 is ~
   IF ISDIGIT(cChar) .OR. ISALPHA(cChar) .OR. ;
      ( nKey >= Qt_Key_Space .AND. nKey <= Qt_Key_Slash ) .OR. ;
      ( nKey >= Qt_Key_Colon .AND. nKey <= Qt_Key_Question ) .OR. ;
      ( nKey >= Qt_Key_BracketLeft .AND. nKey <= Qt_Key_AsciiTilde ) .OR. ;
      ( nKey >= Qt_Key_nobreakspace .AND. nKey <= Qt_Key_ydiaeresis ) .OR. ;
      nKey == Qt_Key_Backspace .OR. nKey == Qt_Key_Delete .OR. ;
      nKey == Qt_Key_Up .or. nKey == Qt_Key_Down             // <<---------Here
      lQtEventStop := .T.
      DO CASE
         CASE /* lNavigationExtend .and. */ nKey == Qt_Key_Up            // <<---------Here
              ::__HmgSendEvent( Qt_Key_Tab, Qt_ShiftModifier )            // <<---------Here

         CASE /* lNavigationExtend .and. */ nKey == Qt_Key_Down            // <<---------Here
              ::__HmgSendEvent( Qt_Key_Tab, Qt_NoModifier )            // <<---------Here

         CASE ::nDataType == TXT_NUMERIC
            ::__HmgProcessNumeric( oQtEvent )
         OTHERWISE
            ::__HmgProcessText( oQtEvent )
      END CASE
   ENDIF

RETURN lQtEventStop

Change this piece of code in "textbox.prg" and test "samples\textbox" ;)

In "hmg.ch" could be so:

Code: Select all

   #translate SET NAVIGATION EXTENDED =>  lNavigationExtend := .T.
All objects that deal with the keyboard would have to be revised, or only in a centralized source "basic.prg" or "control.prg" maybe would be easier to do this work.

What do you think ?

Best Regards,

Rossine.
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: "SET NAVIGATION EXTENDED" in HMG.4

Post by l3whmg »

Hi Rossine :)
Yes I know this can be possible! IMHO, the problem is: how can be possible to handle (or not) everywhere these keys?
When I answer to you I omitted some knowledge for you.
I think you are more comfortable than me with OOP (class and object) to follow my logic:

1) "every" object/class it is inherit from control and control is inherit from basic.
2) every object can get some event/signal connected by default and can get some particular event/signal connected

When we speaking about handling "ENTER" or "ROWS", we must be in agreement when, where and how these keys are handled.

For example: ENTER is always handled.
We must change the __HmgConnect (and related __HmgDisconnect) default method (and customized for single object) and add this line

Code: Select all

::oQtObject:connect( QEvent_KeyPress, {|oQtEvent| ::ProcessKeyPressed(oQtEvent)}) 
First problem: not every QT object can handle this event/signal
Second problem: not every QT object handle this event/signal in the same way (button / label)

Than, we can code the method ProcessKeyPressed as a mix of current code and your code.....
Third problem: some object handle or it requires a different managing for key press handling (see TEXTBOX as you write) and remember the previous...
Fourth problem: (I'm not sure about this, but....) we must use strongFocus for every object to handle Qevent_KeyPress but not every QT object need / handle this setting.

So what I means is: for a single object (TEXTBOX) this handling can be performed because it's already "improved" by default in some way but not used. How can activate this handling in a bigger contest? When I'm on a label (it is focused and it has tabstop) and I press DOWN ARROW, how can be handled or can be handled? Else we obtains: for some objects arrows can be used for other not: it's a good behaviour?

Please try to use my previous example and look at problems; check with different objects: Textbox, Button, Label, Menu, ComboBox and so on.

I will be very enjoy to use your suggestion if can be used in a "generalized" solution.

Cheers
Luigi from Italy
www.L3W.it
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: "SET NAVIGATION EXTENDED" in HMG.4

Post by mrduck »

Fifth: why do you want use a GUI program as a text-mode program ? Probably your users will be more confused using arrow keys/enter to move between GUI fields than the standard TAB key !

They will came after you asking that Word forms will act like your program.... on the contrary, I think that you must educate your users that IT IS A GUI PROGRAM ! And it must work as a GUI PROGRAM.

I won't accept nor justify the use of up/down keys in a gui program, except in a cell based grid...

But I understand we can make this feature optional. The code you published is not perfect but it is a starting point for Textboxes. It won't fit for every object !!!!


Anyway, here is an implementation done with subclassing.

Code: Select all

METHOD __HmgProcessKey( oQtEvent ) CLASS ROSSINE_TEXTBOX
  LOCAL lQtEventStop
   LOCAL cChar := oQtEvent:text()
   LOCAL nKey := oQtEvent:key()

   // must be improved eg ALT+0126 is ~
   IF nKey == Qt_Key_Up .or. nKey == Qt_Key_Down             // <<---------Here
      lQtEventStop := .T.
      DO CASE
         CASE /* lNavigationExtend .and. */ nKey == Qt_Key_Up            // <<---------Here
              ::__HmgSendEvent( Qt_Key_Tab, Qt_ShiftModifier )            // <<---------Here
         CASE /* lNavigationExtend .and. */ nKey == Qt_Key_Down            // <<---------Here
              ::__HmgSendEvent( Qt_Key_Tab, Qt_NoModifier )            // <<---------Here
      END CASE
   ELSE
            lQtEventStop := Super:__HmgProcessKey( oQtEvent )
   ENDIF
RETURN lQtEventStop
Post Reply