Memo problem

Memo problem

Postby Randal » Thu Dec 09, 2010 5: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
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm

Re: Memo problem

Postby Randal » Fri Dec 17, 2010 4: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
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 15 guests