mouse wheel to increase or decrease a value


👉 BlitzCoder will be building a new platform and other plans to preserve and continue the Blitz legacy.

To be able to achieve this goal, we need your support by becoming a Patreon Paid Member 👈

 

Tweet blitz3d blitzbasic input code-archives
RemiD

i have probably already posted such example in some of my others code examples, but i don't remember where or when...

use the mouse wheel to increase (+1) or decrease (-1) a value.

;mouse wheel to increase (+1) or decrease (-1) a value by RemiD (20230928)

Graphics( 854, 480, 32, 2 )

Global MZOld% = 0
Global MZCur% = 0
Global MWheel% = 0

Global ValueInt% = 0

Main()

End()

Function Main()

 Repeat 

  MWheel = 0
  MZCur = MouseZ()
  If(MZCur > MZOld)
   MWheel = + 1
   MZOld = MZCur
  ElseIf(MZCur < MZOld)
   MWheel = - 1
   MZOld = MZCur
  EndIf

  If( MWheel = + 1 )
   ValueInt = ValueInt + 1
  Else If( MWheel = - 1 )
   ValueInt = ValueInt - 1
  EndIf

  SetBuffer( BackBuffer() )
  ClsColor( 000, 000, 000 ) : Cls()

  Color( 240, 240, 240 )
  Text( 854/2-StringWidth(ValueInt)/2, 480/2-StringHeight(ValueInt)/2, ValueInt )

  Flip(1)

 Until( KeyDown(1)=1 )

End Function

Reply To Topic (minimum 10 characters)

Please log in to reply