Page 2 of 2

Re: dcget keyblock

Posted: Mon Oct 18, 2010 2:11 pm
by rdonnay
Zdeno -

I'm going to need more time to figure out a solution.

Roger

Re: dcget keyblock

Posted: Mon Oct 18, 2010 11:51 pm
by skiman
Hi Jack,

Nice solution for the keyblock.

I don't know if you are aware that there is an undocumented milliseconds() function in Xbase++? Maybe it could be of help to make your timer class with less code?

Re: dcget keyblock

Posted: Tue Oct 19, 2010 4:29 am
by BruceN
is that millisec() the same as sleep() except in 1/1000 instead of 1/00?

Re: dcget keyblock

Posted: Tue Oct 19, 2010 6:52 am
by skiman
Hi,

No, it is the same as seconds(), except it gives you the milliseconds() since midnight.

Re: dcget keyblock

Posted: Wed Oct 20, 2010 11:48 am
by Zdeno Bielik
jdsoft wrote:In your keyblock, insert the code: ....
Hi Jack,

please, can you compile and run attached example and tell me, where is problem?
It looks it still works how I don't want, all code after stoped time is executed N times...
so different is only that it is not running immediatelly after each character is typing, but at once N times after delay.

Zdeno

Re: dcget keyblock

Posted: Wed Oct 20, 2010 1:53 pm
by rdonnay
Here is a sample that appears to be doing what you want:

Code: Select all

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

FUNCTION Main()

LOCAL GetList[0], cGet := Space(50), aDir := Directory(), oBrowse, bAction

bAction := {|oGet|MyKeyboard(oBrowse,oGet)}

@ 0,0 DCGET cGet KEYBLOCK {|n,x,oGet|MyKeyDelay(n,0.8,oGet)}

@ 2,0 DCBROWSE oBrowse DATA aDir SIZE 60,25

DCBROWSECOL ELEMENT 1 HEADER 'File Name' WIDTH 50 PARENT oBrowse

DCUSEREVENT xbeP_User + 10 ACTION bAction

DCREAD GUI FIT

RETURN nil

* ----------

FUNCTION MyKeyDelay( nKey, nDelay, oGet, bBlock )

LOCAL nEvent, oXbp, mp1, mp2, nSeconds := Seconds()

DEFAULT nDelay := 0

IF nDelay > 0
  DO WHILE Seconds() - nSeconds < nDelay .AND. ( nKey < 60000 )
    nEvent := AppEvent(@mp1,@mp2,@oXbp,.1)
    IF Valtype(oXbp) == 'O'
       oXbp:handleEvent(nEvent,mp1,mp2)
    ENDIF
  ENDDO
ENDIF

PostAppEvent( xbeP_User + 10, oGet )

RETURN nil

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

STATIC FUNCTION MyKeyboard( oBrowse, oGet )

LOCAL cBuffer := Trim(oGet:get:buffer), nArrayElement

nArrayElement := AScan(oBrowse:dataSource,{|a|Upper(a[1])=Upper(cBuffer)})

IF nArrayElement > 0
  oBrowse:arrayElement := nArrayElement
ENDIF

oBrowse:refreshAll()
DC_ClearEvents()

RETURN nil

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

PROC appsys ; return

Re: dcget keyblock

Posted: Wed Oct 20, 2010 11:06 pm
by Zdeno Bielik
Roger,

thank you!!! thank you!!! thank you!!! :clap: :clap: :clap:

It looks it is OK now, super!!! :dance:

Zdeno