FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Memo problem
Posts: 284
Joined: Mon Oct 24, 2005 08:04 PM
Memo problem
Posted: Thu Dec 09, 2010 05:35 PM

All,

I recently upgraded to FWH 1009 and the behaviour of a memo edit has changed. The problem is when clicking the Date button the action is performed and the cursor is positioned at the end of the text that is inserted (date/time). However, if the user presses Alt+D the text is inserted however, focus moves to the next control instead of staying in the memo. So, the behaviour is different depending on how the ACTION is activated.

Below is a FWH sample I modified a little to show the problem. When the dialog is displayed the cursor is positioned at the beginning of the text. Press Enter once or twice to move the existing text down, then press the up arrow to move the cursor to the top line, first leftmost position. Do this and click the Date button and you can see the text is inserted and the cursor is properly positioned on space after the date/time and on the same line. Do it again but use Alt+D and focus is moved to the next control.

Also, this only happens when moving the cursor to the beginning of the memo and the first line is blank. I thought perhaps it was some kind of typeout behaviour but it doesn't do this if you click the Date button using the mouse.

include "Fivewin.ch"

FUNCTION MAIN()

LOCAL oDlg

LOCAL oGet, cVar := "Hello World!" + CRLF + "This is a test"
LOCAL cStr, cTemp

DEFINE DIALOG oDlg

@ 1, 1 GET oGet VAR cVar MEMO SIZE 80, 30

// So text isn't selected/highlighted
oGet:bGotFocus := {|| oGet:setpos(oGet:nPos)}

@ 3, 1.5 BUTTON "&Close"; 
       ACTION oDlg:End()

@ 3, 8.5 BUTTON "&Date"; 
         ACTION ( oGet:LostFocus(), ;
           oGet:SetFocus(), ;
           cTemp := oGet:varGet(),  ;
           cStr  := dtoc(date())+' '+Time()+' ', ;
           oGet:varPut( substr( cTemp, 1, oGet:nPos) + cStr + substr(cTemp, oGet:nPos) ), ;
           oGet:Refresh(), ;
           oGet:SetPos( len(substr(cTemp, 1, oGet:nPos) + cStr) ), ;
           oGet:SetFocus() )

ACTIVATE DIALOG oDlg ; 
         CENTER

RETURN NIL

Randal

Posts: 284
Joined: Mon Oct 24, 2005 08:04 PM
Re: Memo problem
Posted: Fri Dec 17, 2010 04:20 PM

For anyone that is interested, the problem was that when the memo control loses focus the ForWhen method in control.prg is executed and if the last key pressed is an up/down arrow focus is moved to the next or previous control. I fixed this problem by adding oDate:oJump := oMemo to the beginning of the button action.

Randal

Continue the discussion