(Solved)how to open url webpage by clicking an image??

Just starting out? Need help? Post your questions and find answers here.
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

(Solved)how to open url webpage by clicking an image??

Post by LESTROSO »

how to open url webpage by clicking an image?? i'm using macos x 10.13.6 and windows 10 ....

hi, i'm trying to launch a web page clicking on a credit image from my purebasic program...but without success ...can you help me please??

Best regards,Lestroso :oops:
Last edited by LESTROSO on Fri Jun 07, 2019 6:37 pm, edited 3 times in total.
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: how to open url webpage by clicking an image??

Post by RSBasic »

Code: Select all

EnableExplicit

CreateImage(1, 100, 100, 24, RGB(255, 0, 0))

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ImageGadget(1, 10, 10, 100, 100, ImageID(1), 0)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
            RunProgram("https://www.google.de")
        EndSelect
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf
Or:

Code: Select all

EnableExplicit

CreateImage(1, 100, 100, 24, RGB(255, 0, 0))

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(1, 10, 10, 100, 100, 0)
  If StartDrawing(CanvasOutput(1))
    DrawImage(ImageID(1), 0, 0)
    StopDrawing()
  EndIf
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
            Select EventType()
              Case #PB_EventType_LeftClick
                RunProgram("https://www.google.de")
            EndSelect
        EndSelect
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf
Image
Image
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: how to open url webpage by clicking an image??

Post by Shardik »

LESTROSO wrote:i'm using macos x 10.13.6 and windows 10 ....
RSBasic's examples only work on Windows. On MacOS you have to use

Code: Select all

RunProgram("Open", "https://www.google.de", "")
In this example in the German forum I demonstrated how to display a website in the default browser on Linux, MacOS and Windows.
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

Re: how to open url webpage by clicking an image??

Post by LESTROSO »

I thank you very much!! it's all ok!! you have solved my problem....Best Regards, Lestroso :) :) :)
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

Re: how to open url webpage by clicking an image??

Post by LESTROSO »

Dear friends...... i try to code this problem but i cant have success with it....My Simple problem is to click an image jpg and open the browser to google... i try this software..can you help me??? please ??? Lestroso :oops: :oops:

Code: Select all

Global FasaImage
Procedure testaimmagini()
 
  Select EventGadget()
          
       Case #Fasaimage
                If EventType() = #PB_EventType_Change
                  Select GetGadgetState(#Fasaimage) 
                                              
                    Case 1
                      Debug #fasaimage
            RunProgram("Open", "https://www.google.com", "") ; this for macintosh
            ;version windows RunProgram("https://www.google.de", "")

                 EndSelect

               EndIf
           EndSelect
           
EndProcedure

wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: how to open url webpage by clicking an image??

Post by wombats »

It is best if you post a runnable program so that we can better see what you are trying to do. It's not clear what you're trying to do there - what type of gadget is #Fasaimage? Why do you check the EventGadget() in a procedure - is it bound to a gadget's event?
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: how to open url webpage by clicking an image??

Post by TI-994A »

LESTROSO wrote:...to click an image jpg and open the browser to google...
This should do it:

Code: Select all

wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
If OpenWindow(0, 0, 0, 200, 200, "ImageGadget", wFlags)
  yourImage = CreateImage(#PB_Any, 180, 180, 32, #Red)  
  imageGadget = ImageGadget(#PB_Any,  10, 10, 10, 10, ImageID(yourImage))
  Repeat    
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        appQuit = 1  
      Case #PB_Event_Gadget
        Select EventGadget()
          Case imageGadget
            CompilerIf #PB_Compiler_OS = #PB_OS_MacOS              
              RunProgram("Open", "https://www.google.com", "")
            CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
              RunProgram("https://www.google.de")
            CompilerEndIf            
        EndSelect       
    EndSelect
  Until appQuit
EndIf
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

Re: how to open url webpage by clicking an image??

Post by LESTROSO »

Dear TI-994A,...your software example...clear my problem...i tryed your software and it works fine! I thank you very much...best regards, Lestroso :D :D :D
Post Reply