Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_OpenFileDIalog$() and MouseButton(1)
#1
When i use _OpenFileDIalog$ to select a file to load, it seems that MouseButton(1) stay to -1 (without press left button) ?!
I need clic to make it change to 0.

How could i make   MouseButton(1) = 0 because left button is not pressed ?

Thanks !
Reply
#2
Code: (Select All)
while _mouseinput: wend 'clear mouse buffer

Do that before invoking the dialog in your code.
Reply
#3
(02-13-2026, 11:13 AM)FellippeHeitor Wrote:
Code: (Select All)
while _mouseinput: wend 'clear mouse buffer

Do that before invoking the dialog in your code.

Thanks for your help!
Unfortunately, it doesn't change anything... after  _OpenFileDialog$(), MouseButton(1) remains at -1.
Reply
#4
Code: (Select All)
Screen _NewImage(800, 600, 32)

Do
    Cls
    Line (0, 0)-(799, 599), _RGB32(50, 50, 50), BF

    ' Bouton "Charger"
    Line (300, 250)-Step(200, 50), _RGB32(100, 100, 100), BF
    Line (300, 250)-Step(200, 50), _RGB32(200, 200, 200), B
    Color _RGB32(255, 255, 255)
    _PrintString (350, 268), "CHARGER"

    ' Affichage état
    _PrintString (10, 30), "_MOUSEBUTTON(1) = " + Str$(_MouseButton(1))

    ' Gestion souris
    While _MouseInput: Wend
    mx = _MouseX
    my = _MouseY
    lb = _MouseButton(1)

    ' CLIC sur bouton Charger
    If lb Then
        If mx >= 300 And mx <= 500 And my >= 250 And my <= 300 Then
            filename$ = _OpenFileDialog$("Load", "", "*.*", "Files", 0)
            _Delay 0.1
        End If
    End If

    _Display
    _Limit 60
Loop Until InKey$ = Chr$(27)

After this, mousebutton(1) stay to -1 !!!
Reply
#5
I meant before line 25
Reply
#6
(02-13-2026, 12:16 PM)FellippeHeitor Wrote: I meant before line 25

Yep, same problem.
Reply
#7
Code: (Select All)
Screen _NewImage(800, 600, 32)

Do
    Cls
    Line (0, 0)-(799, 599), _RGB32(50, 50, 50), BF

    ' Bouton "Charger"
    Line (300, 250)-Step(200, 50), _RGB32(100, 100, 100), BF
    Line (300, 250)-Step(200, 50), _RGB32(200, 200, 200), B
    Color _RGB32(255, 255, 255)
    _PrintString (350, 268), "CHARGER"

    ' Affichage état
    _PrintString (10, 30), "_MOUSEBUTTON(1) = " + Str$(_MouseButton(1))

    ' Gestion souris
    While _MouseInput: Wend
    mx = _MouseX
    my = _MouseY
    lb = _MouseButton(1)

    ' CLIC sur bouton Charger
    If lb Then
        If mx >= 300 And mx <= 500 And my >= 250 And my <= 300 Then
            Do While _MouseButton(1)
                While _MouseInput: Wend
                _Limit 60
            Loop

            filename$ = _OpenFileDialog$("Load", "", "*.*", "Files", 0)
            _Delay 0.1
        End If
    End If

    _Display
    _Limit 60
Loop Until InKey$ = Chr$(27)


it seems to work like that ...
Reply
#8
Dang! that's weird but this works
Code: (Select All)
Screen _NewImage(800, 600, 32)

Do
    Cls
    Line (0, 0)-(799, 599), _RGB32(50, 50, 50), BF

    ' Bouton "Charger"
    Line (300, 250)-Step(200, 50), _RGB32(100, 100, 100), BF
    Line (300, 250)-Step(200, 50), _RGB32(200, 200, 200), B
    Color _RGB32(255, 255, 255)
    _PrintString (350, 268), "File Dialog"

    ' Gestion souris
    While _MouseInput: Wend
    mx = _MouseX
    my = _MouseY
    lb = _MouseButton(1)

    ' Affichage état
    _PrintString (10, 30), "_MOUSEBUTTON(1) = " + Str$(lb)


    ' CLIC sur bouton Charger
    If lb Then
        If mx >= 300 And mx <= 500 And my >= 250 And my <= 300 Then
            filename$ = _OpenFileDialog$("Load", "", "*.*", "Files", 0)
            '_Delay 0.1
            _PrintString (50, 330), filename$ + "    zzz... click mouse again"
            _Display
        End If
        Do '                                                      need to wait
            i = _MouseInput '  read #2                        until the mouse
        Loop Until Not _MouseButton(1) '                      button is released
    End If

    _Display
    _Limit 60
Loop Until InKey$ = Chr$(27)

Apparently another mouse click is needed to get clear of click of button and Dialog. 

Dialog must have a bug?
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#9
Ok I Fantomas has better solution that does not require extra click of mouse.

Here is another, just move that delay to right after lb is detected from original post!
Code: (Select All)
Screen _NewImage(800, 600, 32)

Do
    Cls
    Line (0, 0)-(799, 599), _RGB32(50, 50, 50), BF

    ' Bouton "Charger"
    Line (300, 250)-Step(200, 50), _RGB32(100, 100, 100), BF
    Line (300, 250)-Step(200, 50), _RGB32(200, 200, 200), B
    Color _RGB32(255, 255, 255)
    _PrintString (350, 268), "CHARGER"

    ' Affichage état
    _PrintString (10, 30), "_MOUSEBUTTON(1) = " + Str$(_MouseButton(1))

    ' Gestion souris
    While _MouseInput: Wend
    mx = _MouseX
    my = _MouseY
    lb = _MouseButton(1)

    ' CLIC sur bouton Charger
    If lb Then

        _Delay .1 ' <<<< get clear of the click FIRST!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

        If mx >= 300 And mx <= 500 And my >= 250 And my <= 300 Then
            filename$ = _OpenFileDialog$("Load", "", "*.*", "Files", 0)
            '  _Delay 0.1  >>>> move this to the above !!!!!!! line
        End If
    End If

    _Display
    _Limit 60
Loop Until InKey$ = Chr$(27)

IMO this one is BETTER! because you avoid a 2nd Mouse Input loop.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#10
i fail to see an use for this.

also in the example just above.  _mousebutton(1) is called twice.  it needs to be restricted to loading the value of lb variable.
hopeless addict of dying in the first few levels of two particular console viewport "roguelike" games
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)