Page 1 of 1

Mouse wheel scrolling in get spinner?

Posted: Wed May 28, 2008 9:14 am
by Otto
How can I get mouse wheel to invoke the up and down actions in a get spinner.
Thanks in advance
Otto

Posted: Thu May 29, 2008 11:19 am
by Natter
oGet:oVScroll:bGoUp
bGoDown
..............

Posted: Thu May 29, 2008 9:10 pm
by Otto
Thank you for your help. I tried your code but it didn't work.
Does someone have a get class changed for mousewheel support?
Thanks in advance
Otto

Posted: Thu May 29, 2008 10:28 pm
by Natter
FUNCTION MAIN()
local nVal := -1
local oGet
private oDlg

DEFINE DIALOG oDlg

@ 1,1 GET oGet VAR nVal;
PICTURE "999" SPINNER
oGet:bChange:={||MyFun()}

@ 1,15 SAY "..."

ACTIVATE DIALOG oDlg CENTER

RETURN NIL

procedure MyFun
oDlg:aControls[2]:SetText(oDlg:aControls[1]:cText())
return
[/code]

Posted: Fri May 30, 2008 5:13 am
by Otto
Hello Natter,
thank you for your sample.
I compiled the sample but here mouse wheel does not work.
I think a get field with mouse wheel support should work either if you click on the scrollbar or it the field has focus and you turn the wheel.
And this is not happen.
Regards,
Otto

Posted: Fri May 30, 2008 6:47 am
by mmercado
Otto wrote:I compiled the sample but here mouse wheel does not work.
Hi Otto:

Taking the Natter's sample try this:

Code: Select all

#include "Fivewin.ch"

Static oGet

Function Main()

   Local oGet, oDlg, ;
         nVal := -1

   DEFINE DIALOG oDlg

   TGet_Modify()

   @  1,  1 GET oGet VAR nVal ;
            PICTURE "999" SPINNER

   oGet:bChange:={ || MyFun( oDlg ) }

   @  1, 15 SAY "..."

   ACTIVATE DIALOG oDlg CENTERED

Return Nil

//---------------------------------------------------------//

Static Function MyFun( oDlg )

   oDlg:aControls[ 2 ]:SetText( oDlg:aControls[ 1 ]:cText() )

Return Nil

//---------------------------------------------------------//

Static Function TGet_Modify()

  Override Method MouseWheel In Class TGet With UseTheWheel

Return Nil

//---------------------------------------------------------//

Static Function UseTheWheel( nKey, nDelta, nXPos, nYPos )

   Local Self := QSelf()

   If nDelta > 0
      Self++
   Else
      Self--
   EndIf

Return Nil
Best regards.

Manuel Mercado

Posted: Fri May 30, 2008 10:07 am
by Otto
Hello Manuel,

Thank you very much for your help. This is working.

I must figure out how to implement this method into TGet class.
I use Harbour too and override I think does not exist in Harbour.

I have uploaded the snip to:
http://www.fwcodesnips.com/

Regards,
Otto

Posted: Fri May 30, 2008 2:05 pm
by mmercado
Otto wrote:I must figure out how to implement this method into TGet class.
The main virtue of Override and Extend procedures is not having to touch original classes for solve very specific cases.

Besides, I'm sure that Antonio has take note of your request for retouching TGet accordantly in a future FWH release.
Otto wrote:I use Harbour too and override I think does not exist in Harbour.
Unfortunately no (at least up to my version 8.02), we hope that the Harbour's people to implement it soon.

Best regards.

Manuel Mercado

Posted: Fri May 30, 2008 2:26 pm
by James Bott
Otto,

Is there a reason that you are not using xHarbour for everything? I use xHarbour exclusively.

James

Posted: Fri May 30, 2008 3:34 pm
by Otto
Hello James, hello Manuel,

Thank you for your help.
No there is not really a reason why I use both.

I tried to insert the method in TGet. I think it should only work on Gets with spinner. Therefore I inserted the proof for lSpinner.

Regards,
Otto

METHOD MouseWheel( nKeys, nDelta, nXPos, nYPos )
IF ::lSpinner=.t.
If nDelta > 0
Self++
Else
Self--
EndIf
ENDIF

Return Nil

//---------------------------------------------------------//