Posts: 6
Threads: 1
Joined: Jun 2022
Reputation:
0
02-13-2026, 10:45 AM
(This post was last modified: 02-13-2026, 10:46 AM by Fantomas.)
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 !
Posts: 35
Threads: 3
Joined: Jul 2023
Reputation:
24
Code: (Select All)
while _mouseinput: wend 'clear mouse buffer
Do that before invoking the dialog in your code.
Posts: 6
Threads: 1
Joined: Jun 2022
Reputation:
0
(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.
Posts: 6
Threads: 1
Joined: Jun 2022
Reputation:
0
02-13-2026, 12:03 PM
(This post was last modified: 02-13-2026, 12:03 PM by Fantomas.)
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 !!!
Posts: 35
Threads: 3
Joined: Jul 2023
Reputation:
24
Posts: 6
Threads: 1
Joined: Jun 2022
Reputation:
0
(02-13-2026, 12:16 PM)FellippeHeitor Wrote: I meant before line 25
Yep, same problem.
Posts: 6
Threads: 1
Joined: Jun 2022
Reputation:
0
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 ...
Posts: 4,695
Threads: 222
Joined: Apr 2022
Reputation:
322
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
Posts: 4,695
Threads: 222
Joined: Apr 2022
Reputation:
322
02-13-2026, 01:37 PM
(This post was last modified: 02-13-2026, 01:40 PM by bplus.)
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
Posts: 188
Threads: 14
Joined: May 2024
Reputation:
20
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
|