Author | Topic: DO WHILE nEvent <> xbeP_Close | |
---|---|---|
Saul | DO WHILE nEvent <> xbeP_Close on Sat, 21 Oct 2006 23:17:48 +0200 Hello, in the xbrowse() class excample the programm waits for an event in the queue. DO WHILE nEvent <> xbeP_Close nEvent := AppEvent( @mp1, @mp2, @oXbp ) oXbp:handleEvent( nEvent, mp1, mp2 ) ENDDO What code have I to add when I want to check if a keystroke A shall activate something. In clipper I have the solution: inkey(0) if chr(lastkey() ) $ "aA" funktion() endif | |
mark carew | Re: DO WHILE nEvent <> xbeP_Close on Mon, 23 Oct 2006 05:48:45 +1000 On Sat, 21 Oct 2006 23:17:48 +0200, Saul wrote: > Hello, > in the xbrowse() class excample the programm waits for an event in the > queue. > > DO WHILE nEvent <> xbeP_Close > nEvent := AppEvent( @mp1, @mp2, @oXbp ) > oXbp:handleEvent( nEvent, mp1, mp2 ) > ENDDO > > What code have I to add when I want to check if a keystroke A shall activate > something. > > In clipper I have the solution: > inkey(0) > if chr(lastkey() ) $ "aA" > funktion() > endif Hi Saul, Look in the documentation at the examples or use your text editor to look through the include files (.ch) for xbeK or search the newsgroup for appevent(, you are looking specifically for xbeP_Keyboard. Just went hunting for it and it's not really explained very well in the documentation (but what is), so here is one of thousands of examples of its use that I have that in my collection of 6560 prgs. HTH Mark ------------------------------------------------ function arrayBrowseLookup(aEdVals,cTitle,aHeadings,oParent) local aPP local cHead local cLook local drawingarea local lForceStable local mp1 local mp2 local nBaseColor local nCol local nEvent local nHigh local nLen local nLenLook local nPeek local nPop local nPtr local nRow local nWide local oBrowse local oDlg local oXbp local uRetVal nWide := ; 11 * (len(aEdvals[1][1]) + len(aEdvals[1][2])) + 3 * nCol := 99 * nRow := 99 * nHigh := len(aEdvals)*20 + 30 * if nHigh > 450 * nHigh := 450 endif oDlg := ; myStdDialog("Choose from " + cTitle,{10,80},{nWide,nHigh},oParent) * broCenterControl(oDlg) * nBaseColor := graMakeRgbColor({200,40,20}) * oDlg:SetColorFG(nBaseColor) * drawingArea := oDlg:drawingArea drawingArea:setFontCompoundName("12.Courier New") drawingArea:SetColorBG(nBaseColor) * oBrowse := ; XbpBrowse():new(; drawingarea,setappwindow(),{1,1},{nWide-10,nHigh-30}):create() * oBrowse:cargo := array(BARR_NO) oBrowse:cargo[BDATA] := aEdvals oBrowse:cargo[BNOLINES] := 1 oBrowse:cargo[BCURLINE] := 1 oBrowse:cargo[BARR_NO] := 1 oBrowse:cargo[BWINDOW] := {oDlg,,DrawingArea} * oBrowse:skipBlock := {|n,obj| SkipArray( n, obj:cargo ) } oBrowse:goTopBlock := {|obj| obj:cargo[ BARR_NO ] := 1 } oBrowse:goBottomBlock := ; {|obj| obj:cargo[BARR_NO] := Len( obj:cargo[ BDATA ] ) } oBrowse:posBlock := {|obj| obj:cargo[ BARR_NO ] } oBrowse:phyposblock := {|obj| obj:cargo[ BARR_NO ]} oBrowse:lastPosBlock := {|obj| Len( obj:cargo[ BDATA ] ) } oBrowse:firstPosBlock := {|obj| 1 } oBrowse:softTrack := .F. * aPP := COL_ARRAY_PRES * nLen := len(aHeadings) * FOR nPtr := 1 TO nLen * cHead := aHeadings[nPtr] * makeOneXbpArrayColumn(oBrowse,nPtr,aPP,cHead) NEXT drawingArea:resize := ; {|mp1,mp2,obj| Resize(oBrowse,mp2) } * oDlg:show() * Display browser. * oBrowse:show() oBrowse:refreshAll() * Set focus to browser * SetAppFocus( oDlg ) SetAppFocus( oBrowse:GetColumn(1) ) * nEvent := 0 * cLook := "" * nLenLook := 0 DO WHILE TRUE nEvent := AppEvent( @mp1, @mp2, @oXbp ) * DO CASE CASE nEvent == xbeP_Keyboard * lForceStable := FALSE do case case mp1 == xbeK_ESC * nCol := 99 * postappevent(xbeP_Close,,,oBrowse) exit case (mp1 > 31 .AND. mp1 < 126) .or. (mp1 == 8) * do case case mp1 == xbeK_BS * nLenLook := len(cLook) * IF nLenLook > 0 * cLook := left(cLook,nLenLook-1) ENDIF case mp1 > 31 .and. mp1 < 126 * cLook += upper(Chr(mp1)) end case IF empty(cLook) * oBrowse:gotop() else nLenLook := len(cLook) * nPeek := ; ascan(; aEdVals,; {|e| ; left(e[1],nLenLook)==cLook ; }; ) * IF nPeek > 0 * oBrowse:goTop() * FOR nPop := 1 to (nPeek-1) * oBrowse:down() NEXT oBrowse:refreshall() ENDIF endif * lForceStable := TRUE * case mp1 == xbeK_ENTER * nCol := oBrowse:colpos * nRow := oBrowse:cargo[BARR_NO] * postappevent(xbeP_Close,,,oBrowse) exit case mp1 == xbeK_DOWN * oBrowse:down() * lForceStable := TRUE * case mp1 == xbeK_UP * oBrowse:up() * lForceStable := TRUE * case mp1 == xbeK_PGDN * oBrowse:pagedown() * lForceStable := TRUE * case mp1 == xbeK_PGUP * oBrowse:pageup() * lForceStable := TRUE * case mp1 == xbeK_LEFT * oBrowse:left() * lForceStable := TRUE * case mp1 == xbeK_RIGHT * oBrowse:right() * lForceStable := TRUE end case IF lForceStable == TRUE * oBrowse:forcestable() ENDIF CASE nEvent == xbeBRW_ItemSelected * nCol := oBrowse:colpos * nRow := oBrowse:cargo[BARR_NO] * postAppevent(xbeP_Keyboard,xbeK_ENTER,,oBrowse) loop otherwise * IF nEvent == xbeP_Close exit ENDIF * oXbp:handleEvent( nEvent, mp1, mp2 ) END CASE enddo * if nCol < 99 * uRetVal := aEdVals[nRow][1] endif oBrowse:destroy() * oDlg:destroy() * return uRetval ------------------------------------------------ | |
James Loughner | Re: DO WHILE nEvent <> xbeP_Close on Sun, 22 Oct 2006 16:27:43 -0400 The good way is to use the keyboard callback codeblock. Or even sub class XbpBrowse and add you own keyboard method to handle any situation. Jim Saul wrote: > Hello, > in the xbrowse() class excample the programm waits for an event in the > queue. > > DO WHILE nEvent <> xbeP_Close > nEvent := AppEvent( @mp1, @mp2, @oXbp ) > oXbp:handleEvent( nEvent, mp1, mp2 ) > ENDDO > > What code have I to add when I want to check if a keystroke A shall activate > something. > > In clipper I have the solution: > inkey(0) > if chr(lastkey() ) $ "aA" > funktion() > endif > > | |
Bernd Reinhardt | Re: DO WHILE nEvent <> xbeP_Close on Sat, 28 Oct 2006 19:03:45 +0200 Hi Saul. We do it in this way: I leave the do while all 2 seconds, or if an action happend. nStartsec := seconds() /* If there a lot events, I exit the do while all 2 seconds */ nIstSec := nStartsec DO WHILE nEvent <> xbeP_Close Ereignis xbeP_Close ab nEvent := AppEvent( @mp1, @mp2, @oXbp, 200 ) wait for 2 seconds if nEvent == xbe_None no event then 2 seconds are over exit elsif nEvent == xbeK_ that's for your Keycode see documentation elseif nEvent = xbeP_Close lEnde := .t. else oXbp:handleEvent( nEvent, mp1, mp2 ) nIstSec := seconds() if (nIstSec - nStartsec) > 2 /* damits bei mausbewegung trotzdem weiter geht */ exit endif endif ENDDO if lEnde exit endif I hope this helps, see also documentation appevent. regards Bernd "Saul" <Saul3@web.de> schrieb im Newsbeitrag news:74ae6faa$593b4f68$8d607@news.alaska-software.com... > Hello, > in the xbrowse() class excample the programm waits for an event in the > queue. > > DO WHILE nEvent <> xbeP_Close > nEvent := AppEvent( @mp1, @mp2, @oXbp ) > oXbp:handleEvent( nEvent, mp1, mp2 ) > ENDDO > > What code have I to add when I want to check if a keystroke A shall activate > something. > > In clipper I have the solution: > inkey(0) > if chr(lastkey() ) $ "aA" > funktion() > endif > > | |
Mahanimann | Re: DO WHILE nEvent <> xbeP_Close on Fri, 03 Nov 2006 23:26:45 +0100 > What code have I to add when I want to check if a keystroke A shall > activate something. I'm a newbie myself and found a great way to do it here: http://www.cjcom.net/tdarticles.htm You will learn a lot from every article there, and especially on event handling in the article "Designing for Mouse and Keyboard". I bought the TopDown lib because of these articles , they contain very crucial information that will give you a kick start in many very important ways (threads, window handling, types of windows etc.). Regards, Mahanimann |