Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Life
#21
DEF SEG and PEEK really not recommended for new code, just there for compatibility to old code.

Code: (Select All)
'=============================== free draw with mouse
If start1 = 2 Then
    'use mouse to draw starting pattern

    'draw STARTING GRID
    For j = 1 To gx
        For k = 1 To gy
            Line (j * res1, k * res1)-(j * res1 + res1, k * res1 + res1), c1~&(mn(j, k)), BF
        Next k
    Next j
    Do

        Do While _MouseInput
        Loop
        x% = _MouseX
        y% = _MouseY
        'Locate 1, 1
        'Print x%, y%
        x1 = Int(x% / res1)
        y1 = Int(y% / res1)
        mn(x1, y1) = 1
        'mn(x1 - 1, y1 - 1) = 1
        'mn(x1 + 1, y1 - 1) = 1
        'mn(x1 + 1, y1 + 1) = 1
        'mn(x1, y1 + 1) = 1
        'mn(x1 + 1, y1) = 1
        'mn(x1, y1 - 1) = 1
        'draw  GRID
        For j = 1 To gx
            For k = 1 To gy
                Line (j * res1, k * res1)-(j * res1 + res1, k * res1 + res1), c1~&(mn(j, k)), BF
            Next k
        Next j

        lc% = _MouseButton(1)  ' <<<< Why not _MouseButton(2) ?????
    Loop Until lc% = -1

Seems like perfect place to try Right Click in your code, instead of Left Mouse Button

PS your screen is too large for me to test the code as is and I think if I reduce the size I mess the setups to try.
b = b + ...
Reply
#22
> @james2464
> It seems tricky to be able to 'capture' a right-click.

This may be helpful -- it is a program that just draws random points, but also checks the left and right mouse buttons and draws colored lines.  It checks for the down-edges (clicks) and up-edges (ends).

> Also, what sort of delay/wait method would be appropriate?

You may already have this answered, but are you interested in "repeat" clicks?  Like repeating keys?  I have a version that adds that, using "TIMER(.001)"

Anyway, thanks for "Life".


Code: (Select All)
_Title "MOUSECKMIN.bas" ' dcromley
Option _Explicit
Dim Shared mx, my, m1Clk, m1Dn, m1End, m2Clk, m2Dn, m2End ' for mouse
Screen _NewImage(1024, 768, 256)

Dim nloop, x1, y1, x2, y2
Locate 8, 2: Print "Drag left or right mouse"
Locate 9, 2: Print "ESC to exit"
Do
  _Limit 1000 '
  nloop = nloop + 1
  ' -- main job is to just set/reset points
  x1 = Int(Rnd * 100): y1 = Int(Rnd * 100)
  If nloop Mod 2 = 1 Then PSet (x1, y1), 0 Else PSet (x1, y1), 15 ' alternate black/white
  ' -- now check Mouse
  MouseCk
  ' button 1 Click, Down, End
  If m1Clk Then Circle (mx, my), 4, 12: Paint (mx, my), 12
  If m1Dn Then PSet (mx, my), 12
  If m1End Then Circle (mx, my), 4, 12
  ' button 2 Click, Down, End
  If m2Clk Then Circle (mx, my), 4, 10: Paint (mx, my), 10
  If m2Dn Then PSet (mx, my), 10
  If m2End Then Circle (mx, my), 4, 10
Loop Until InKey$ = Chr$(27)
System

Sub MouseCk () ' get mouse info
  Static m1Prev, m2Prev ' for getting edges (Clk and End)
  m1Clk = 0: m1End = 0: m2Clk = 0: m2End = 0
  While _MouseInput: Wend ' clear
  mx = _MouseX: my = _MouseY
  m1Dn = _MouseButton(1) ' button 1 processing
  If m1Dn Then ' Btn 1 down
    If Not m1Prev Then m1Clk = -1 ' if down-edge, then it is a Click
  Else ' Btn 1 up
    If m1Prev Then m1End = -1 ' if up-edge, then it is the End
  End If
  m2Dn = _MouseButton(2) ' button 2 processing
  If m2Dn Then ' Btn 2 down
    If Not m2Prev Then m2Clk = -1 ' if down-edge, then it is a Click
  Else ' Btn 2 up
    If m2Prev Then m2End = -1 ' if up-edge, then it is the End
  End If
  m1Prev = m1Dn: m2Prev = m2Dn ' for next time
End Sub
___________________________________________________________________________________
I am mostly grateful for the people who came before me.  Will the people after me be grateful for me?
Reply
#23
(08-15-2022, 02:13 PM)bplus Wrote:         lc% = _MouseButton(1)  ' <<<< Why not _MouseButton(2) ?????
    Loop Until lc% = -1

Seems like perfect place to try Right Click in your code, instead of Left Mouse Button


Good catch...thank you.

I simply changed these two lines to this:

        rc% = _MouseButton(2)  
    Loop Until rc% = -1


And it works perfectly!   This routine was not set up for any clicking, so the drawing was just hovering with the mouse.   The first and only click being a right-click works without issue to exit the loop.

I might not have time in the next day or two but I look forward to sorting it out in the other loop.   Cheers.
Reply
#24
(08-15-2022, 06:49 PM)dcromley Wrote: > @james2464
> It seems tricky to be able to 'capture' a right-click.

This may be helpful -- it is a program that just draws random lines, but also checks the left and right mouse buttons and draws colored lines.  It checks for the down-edges (clicks) and up-edges (ends).

> Also, what sort of delay/wait method would be appropriate?

You may already have this answered, but are you interested in "repeat" clicks?  Like repeating keys?  I have a version that adds that, using "TIMER(.001)"

Anyway, thanks for "Life".

Thank you, this is a perfect example.   I'll study this for sure...it works really well with both left and right buttons.
Reply




Users browsing this thread: 1 Guest(s)