Page 1 of 1

Ubuntu 24.04: #PB_Event_LeftClick

Posted: Fri Jun 13, 2025 5:49 am
by marcoagpinto
This code behaves differently on Windows vs Ubuntu 24.04.

I detect the left-click of the mouse to exit the about window of my app, but I assure that I don't click on any hyperlink.

However, on Ubuntu the event gadget on left-click is always 0, so it always exits the about window even if I click on a hyperlink.

Is there a way to fix it?

Thanks!


Code: Select all

#HYPERLINK_WINDOW_ABOUT_CODER_EMAIL=1000

OpenWindow(1,10,10,800,600,"Testing",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget)    
OpenWindow(2,0,0,640,480,"About",#PB_Window_WindowCentered,WindowID(1))
DisableWindow(1,#True)


  HyperLinkGadget(#HYPERLINK_WINDOW_ABOUT_CODER_EMAIL,10,10,200,20,"marcoagpinto@test.test",#Red)



  okay=#False
  Repeat
      
    event=WaitWindowEvent()
    event_menu=EventMenu()
    event_gadget=EventGadget()
      
     
    If event=#PB_Event_CloseWindow
      okay=#True     
    EndIf      
    
   ; Left-click to exit, except URL and contact e-mails click  
   If event=#PB_Event_LeftClick
     
Debug "LEFT-CLICK"     
Debug "event:"+event
Debug "event_menu:"+event_menu
Debug "event_gadget:"+event_gadget
     
    If event_gadget<>#HYPERLINK_WINDOW_ABOUT_CODER_EMAIL
            ; ADD HERE THE OKAY=#TRUE
    EndIf
  EndIf
    
    
    Select event 
          
      Case #PB_Event_Gadget       
         Select event_gadget
              
          ; Link to e-mail Marco
          Case #HYPERLINK_WINDOW_ABOUT_CODER_EMAIL  
            
Debug "CLICKED ON THE HYPERLINK"
Debug "event:"+event
Debug "event_menu:"+event_menu
Debug "event_gadget:"+event_gadget
            
              ; ADD HERE THE CODE TO OPEN THE EMAIL CLIENT
         EndSelect
    EndSelect
    
    

  Until okay=#True

    
  ; Close the About window and activate the main window
  DisableWindow(1,#False)
  CloseWindow(2)

Re: Ubuntu 24.04: #PB_Event_LeftClick

Posted: Fri Jun 13, 2025 9:02 am
by moulder61
@marcoagpinto

I don't pretend to know much about PB and programming, but you're using Linux so I'm interested. :D

Also, I choose not to use Ubuntu for various reasons, so my OS and the windowing toolkit may be different to yours and that may be a factor.

Having said that, your code seems to work OK for me, according to the debug output, I think?

Moulder.

Image

Re: Ubuntu 24.04: #PB_Event_LeftClick

Posted: Fri Jun 13, 2025 9:09 am
by marcoagpinto
The whole idea of my code is the "About" window of my app.

Clicking anywhere in the window should change the variable: okay=#True

But I have hyperlinks in it and I don't want the window to close if you click on them.

However, left-clicking overrides the hyperlinks clicking, since it ignores them.

Re: Ubuntu 24.04: #PB_Event_LeftClick

Posted: Fri Jun 13, 2025 9:12 am
by moulder61
I noticed you were using PB621 and I'm still running PB611, so I tried it on PB621b10 just to make sure and it still works OK for me.

By OK I mean clicking the hyperlink seems to be generating event gadget 1000 rather than 0.

Moulder.

Re: Ubuntu 24.04: #PB_Event_LeftClick

Posted: Fri Jun 13, 2025 9:17 am
by moulder61
The code you posted doesn't actually work in the way you describe. It only checks for #PB_Event_CloseWindow.

I'm only going by the debug output as to whether it looks like it should work.

Moulder.

Re: Ubuntu 24.04: #PB_Event_LeftClick

Posted: Fri Jun 13, 2025 9:28 am
by marcoagpinto
The whole point is that if I check for the left mouse click, the other two variables in WaitWindowsEvent() come out as 0.

In Windows it works the way it should, I believe.

If I left-click over a gadget the other two variables should also include the gadget, I believe.

Re: Ubuntu 24.04: #PB_Event_LeftClick

Posted: Fri Jun 13, 2025 9:47 am
by moulder61
Maybe I don't understand it properly, but presumably, two different events/gadgets giving different numbers would allow you to tell which was happening and how to code for that eventuality? If they all show as 0, how do you know the difference?

I'm sure Windows and Linux do things differently, and PB probably behaves differently on those systems too. All I can say is that on my system, what you want to happen seems to be happening.

I'm sure I could manage to work out how to get the window to close or open an email link programmatically if I had to. :shock:

Moulder.

Re: Ubuntu 24.04: #PB_Event_LeftClick

Posted: Fri Jun 13, 2025 10:07 am
by marcoagpinto
Okay, I will write it in another way.

Clear the DEBUG window and left-click on the hyperlink gadget.

The correct for me would it be to show:
17
1000
1000

and not:
17
0
0

Re: Ubuntu 24.04: #PB_Event_LeftClick

Posted: Fri Jun 13, 2025 10:32 am
by moulder61
If you look at my previous image the hyperlink is showing as 3 1000 1000 and the left click 17 0 0.

I did notice that clicking on the hyperlink generates two events, hyperlink gadget and left click, so could that be why it closes the window when you click the hyperlink?

I was chopping the code about to see if I could get it working and it seems that, from memory, you might need an event handler routine? Something to separate out the two events?

I have it working so that clicking the hyperlink opens a message requester, but when I close that it closes the windows too so it is counting it as a left click as well.

Sorry if I'm not much help, but it's interesting to me to try to solve the problem anyway. I don't get out much. :?

Moulder.

Re: Ubuntu 24.04: #PB_Event_LeftClick

Posted: Fri Jun 13, 2025 10:48 am
by drgolf
Hello,

On Pb 6.21 with Ubuntu 24.04.2 LTS

This code works like on windows 10 pro 64 (just add windowevent().

Code: Select all

#HYPERLINK_WINDOW_ABOUT_CODER_EMAIL=1000

OpenWindow(1,10,10,800,600,"Testing",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget)    
OpenWindow(2,0,0,640,480,"About",#PB_Window_WindowCentered,WindowID(1))
;DisableWindow(1,#True)


  HyperLinkGadget(#HYPERLINK_WINDOW_ABOUT_CODER_EMAIL,10,10,200,20,"marcoagpinto@test.test",#Red)

  okay=#False
  Repeat
      
    event=WaitWindowEvent()
    event_menu=EventMenu()
    event_gadget=EventGadget()
      
     
    If event=#PB_Event_CloseWindow
      okay=#True     
    EndIf      
    
   ; Left-click to exit, except URL and contact e-mails click  
   If event=#PB_Event_LeftClick
     
Debug "LEFT-CLICK"     
Debug "event:"+event
Debug "event_menu:"+event_menu
Debug "event_gadget:"+event_gadget
     
    If event_gadget<>#HYPERLINK_WINDOW_ABOUT_CODER_EMAIL
      ;          ; ADD HERE THE 
      OKAY=#True
    EndIf
  EndIf
    
    
    Select event 
          
      Case #PB_Event_Gadget       
         Select event_gadget
              
          ; Link to e-mail Marco
          Case #HYPERLINK_WINDOW_ABOUT_CODER_EMAIL  
            
Debug "CLICKED ON THE HYPERLINK"
Debug "event:"+event
Debug "event_menu:"+event_menu
Debug "event_gadget:"+event_gadget
;>>>>>>>>>>>><<<
;>>>>>>>>>>>>><<<<<<<
WindowEvent()   
;>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>><<<<
              ; ADD HERE THE CODE TO OPEN THE EMAIL CLIENT
         EndSelect
    EndSelect
    
    

  Until okay=#True

    
  ; Close the About window and activate the main window
  DisableWindow(1,#False)
  CloseWindow(2)


Re: Ubuntu 24.04: #PB_Event_LeftClick

Posted: Fri Jun 13, 2025 11:50 am
by moulder61
@drgolf

That seems to work nicely. :D

I would have got there eventually. Maybe? :P

Moulder.

Re: Ubuntu 24.04: #PB_Event_LeftClick

Posted: Fri Jun 13, 2025 6:20 pm
by marcoagpinto
It worked!

Thank you!

Only now I tried it since I was very scared that it might not work.

:twisted: :twisted: :twisted: :twisted: :twisted: