Page 1 of 1

DC_XbpGetLbClick / GoToEnd

Posted: Wed Mar 17, 2010 6:15 am
by Markus Walter
Hello Roger,

you posted this in changes-Forum:

1072. Added new Get-Set function: DC_XbpGetLbClick(). This is used to post a
code block to evaluate when the left mouse button is clicked in any
DCGET in the application. This code block can be used to position the
mouse cursor to the end of the get. Example:

DC_XbpGetLbClick( {|x,y,o|GoToEnd(o)} )

STATIC FUNCTION GoToEnd( oGet )
LOCAL nPos := oGet:get:pos
IF nPos > Len(Trim(oGet:buffer))
PostAppEvent(xbeP_Keyboard,xbeK_END,,oGet)
PostAppEvent(xbeP_Keyboard,xbeK_END,,oGet)
ENDIF
RETURN nil

Does this still work for you with the first click in a dcget (if another dcget has focus first). I use 252 and use a very simular solution, but with the first click in a dcget oGet:get:pos (and o:queryMarked()[2]) also gives 1 (and not the real pos). If a DCGET has the focus and using left click, all works fine...

Can you please have a look?

Greetings
Markus

Re: DC_XbpGetLbClick / GoToEnd

Posted: Wed Mar 17, 2010 7:04 am
by rdonnay
I can confirm the behavior you described in my test program (below).
I really don't have a solution for you. It will take a lot more work.
Maybe someone will have the time to experiment with this.

Code: Select all

#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"

FUNCTION Main()

LOCAL GetList[0], cString := 'This is a string                  '

DC_XbpGetLbClick( {|x,y,o|GoToEnd(o),(wtf o)} )

@ 0,0 DCGET cString
@ 1,0 DCGET cString
@ 2,0 DCGET cString
@ 3,0 DCGET cString

DCREAD GUI FIT TITLE 'GotoEnd Test'

RETURN nil

* -----------

PROC appsys ; return

* -----------

STATIC FUNCTION GoToEnd( oGet )
LOCAL nPos := oGet:get:pos

IF nPos > Len(Trim(oGet:buffer))
  PostAppEvent(xbeP_Keyboard,xbeK_END,,oGet)
  PostAppEvent(xbeP_Keyboard,xbeK_END,,oGet)
ENDIF
RETURN nil

Re: DC_XbpGetLbClick / GoToEnd

Posted: Wed Mar 17, 2010 8:16 am
by Markus Walter
Hello Roger,

i play all the day with this (especially it is not with the alaska xbpget).

I found the setInputFocus-Block in your DC_XbpGet:Init()

Code: Select all

  ::setInputFocus := {|x,y,o| ;
                       o:DateFlag := .T., ;
                       o:Home(), ;
                       DC_HiliteGets(o,1,o:getList:getOptions[nGETOPT_HILITECOLOR]), ;
                       DC_ColorGets(o,1,o:getList:getOptions[aGETOPT_COLORGETS]), ;
                       _PopupButtonShow(o,.t.) }
I think the o:Home() can explain the behaviour, doesn't it?

Re: DC_XbpGetLbClick / GoToEnd

Posted: Wed Mar 17, 2010 8:30 am
by rdonnay
Yes, I forgot about that.

You can replace it like so:

Code: Select all

bMyFocus := ;
           {|x,y,o| DC_HiliteGets(o,1,o:getList:getOptions[nGETOPT_HILITECOLOR]), ;
                       DC_ColorGets(o,1,o:getList:getOptions[aGETOPT_COLORGETS]) }

@ .. DCGET myGet EVAL {|o|o:setInputFocus := bMyFocus}

Re: DC_XbpGetLbClick / GoToEnd

Posted: Wed Mar 17, 2010 8:54 am
by Markus Walter
Hi Roger,

what about
o:DateFlag := .T.
and
_PopupButtonShow(o,.t.) ?

Do you know why o:home() was necessary?

Re: DC_XbpGetLbClick / GoToEnd

Posted: Wed Mar 17, 2010 10:48 am
by rdonnay
Hi Roger,

what about
o:DateFlag := .T.
and
_PopupButtonShow(o,.t.) ?

Do you know why o:home() was necessary?
Ok, you can put the o:dateFlag back in. I don't remember why it's there.
_PopupButtonShow() make sure the popup button is displayed when the get receives focus.
It's only needed when using the autohide feature of the popup button.

You can't use it because it's a static function.
I will need to make it into a public function.

o:home() has been in there for 10 years.
I don't want to remove it and cause regression.

Re: DC_XbpGetLbClick / GoToEnd

Posted: Thu Mar 18, 2010 2:31 am
by Markus Walter
Hi Roger,

perhaps o:home() is to prevent marking text with a single click? Since i use my own setinputfocus() (without this o:home()), sometimes the text in the get is marked by clicking first time in the get (normal lbclick)...

I have some DCGETs which are allways marked with a single lbclick (coming fro, outside the get), others not, strange. I will test more...