Page 1 of 1

Cursor/Insert-Position with a dcget

Posted: Mon Apr 12, 2010 8:14 am
by Markus Walter
Hello Roger,

i have a problem and can't find a solution, perhaps you can help...

I want to have the Cursor not on the first position of a dcget (here on the second), but i can't reach the goal (perhaps i am just overworked...).

postappevent() is not a solution. I have some problems with your dc_readguitypeahead()-Solution, i try to work around. But therefor i need a solution for the cursor beeing not on the first position...


Here is my test code (the cursor should be behind the "A"):

Code: Select all

#include "dcdialog.ch"
#include "appevent.ch"

function Appsys()
return NIL

procedure main()
local getlist := {}, getoptions := {}, lRet, cName := "A             ", oGet

  readinsert(.t.)

  @ 5, 5 DCGET cName OBJECT oGet  // eval {|o| /*o:get:right()*/o:get:pos++, o:SetMarked({2,2}), dc_getrefresh(oGet) } 

  DCGETOPTIONS TITLE "Test"
  DCREAD GUI TO lRet OPTIONS getoptions ADDBUTTONS FIT EVAL {|o| oGet:get:pos++, oGet:SetMarked({2,2}), dc_getrefresh(oGet) }

RETURN
Can you help?

Re: Cursor/Insert-Position with a dcget

Posted: Mon Apr 12, 2010 10:30 pm
by Wolfgang Ciriack
Hi Markus,
i use this function, to set the cursor at the end of the content of a GET, perhaps you can adapt it to your needs:

Code: Select all

.....DCGET.....
       GETEVAL {|o|o:setInputFocus:={|a,b,o|EndOfGet(o,GetOptions)}}

****************************************************
PROCEDURE EndOfGet(oXbp, GetOptions,lPlusOne) // lPlusOne=.T. for space at the end
LOCAL x                                       //    of the get, this is the default

DC_ValType(@lPlusOne,.T.)

x := Len(alltrim(oXbp:getdata()))+IIF(lPlusOne,2,1)
Re_ColorGets(oXbp,1,GetOptions)
x := IIF(x<IIF(lPlusOne,3,2), 1, x)     // If empty goto position 1
oXbp:Get:Pos := x
oXbp:setMarked({x,x})                   //   put cursor at end of text
RETURN
*************************************************
FUNCTION Re_ColorGets( o, nMode, GetOptions )
LOCAL aPres, aColor
IF valType(GetOptions) = "A"
  aColor := GetOptions[aGETOPT_COLORGETS]
ELSE
  aColor := DC_GetOptDefault()[aGETOPT_COLORGETS]
ENDIF

IF !Empty(aColor)
  IF Len(aColor) < 2
    AAdd(aColor,{ GRA_CLR_BLACK, GRA_CLR_WHITE })
  ENDIF
  IF nMode = 1
    aPres := { { XBP_PP_FGCLR, aColor[1,1] } , { XBP_PP_BGCLR, aColor[1,2] } }
  ELSE
    aPres := { { XBP_PP_FGCLR, aColor[2,1] } , { XBP_PP_BGCLR, aColor[2,2] } }
  ENDIF
  o:setPresParam(aPres)
ENDIF
RETURN nil


Re: Cursor/Insert-Position with a dcget

Posted: Tue Apr 13, 2010 4:50 am
by skiman
Hi,

I'm using the following in a popup clause of a GET.
...
POPUP {|a,b,c,o| ...,PostAppEvent( xbeP_Keyboard, xbeK_END,, b ),;
PostAppEvent( xbeP_Keyboard, xbeK_RIGHT,, b ),DC_GetRefresh(GetList) }

The result is that the cursor is placed after the content with the END and is moving a space to the right with the xbeK-RIGHT.

I suppose this should also work in other cases.

Re: Cursor/Insert-Position with a dcget

Posted: Wed Apr 14, 2010 2:12 am
by Markus Walter
Hi Chris,

no postappevent is not a solution for my problem. If a user writes very fast, it is possible that next one or two keyboard-events are in the eventqueue before a postappevent like this comes in. But i have now a solution (i modified wolfgang's sample).

Now i work around a design problem of Roger's DC_ReadGuiTypeAhead()-Implementation. But i will open a seperate thread for this, when i am ready with this...

Re: Cursor/Insert-Position with a dcget

Posted: Wed Apr 14, 2010 11:14 pm
by wkedv
Hi Markus,

why you dont use the Cursor-Navigations like oGet:end(), home() ... etc ?

Kurt

Re: Cursor/Insert-Position with a dcget

Posted: Thu Apr 15, 2010 1:12 am
by Markus Walter
Hi Kurt,

because they didn't work there...