It is currently Tue Dec 10, 2019 10:56 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: (Solved)how to open url webpage by clicking an image??
PostPosted: Tue Jun 04, 2019 6:35 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Nov 03, 2005 12:30 pm
Posts: 117
Location: Italy
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.

Top
 Profile  
Reply with quote  
 Post subject: Re: how to open url webpage by clicking an image??
PostPosted: Tue Jun 04, 2019 6:43 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1108
Location: Berlin (Germany)
Code:
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:
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

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: how to open url webpage by clicking an image??
PostPosted: Tue Jun 04, 2019 8:04 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1657
Location: Germany
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:
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: how to open url webpage by clicking an image??
PostPosted: Wed Jun 05, 2019 3:18 pm 
Offline
Enthusiast
Enthusiast
User avatar

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


Top
 Profile  
Reply with quote  
 Post subject: Re: how to open url webpage by clicking an image??
PostPosted: Thu Jun 06, 2019 9:44 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Nov 03, 2005 12:30 pm
Posts: 117
Location: Italy
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:
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



Top
 Profile  
Reply with quote  
 Post subject: Re: how to open url webpage by clicking an image??
PostPosted: Thu Jun 06, 2019 9:56 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 508
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: how to open url webpage by clicking an image??
PostPosted: Fri Jun 07, 2019 2:56 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2213
Location: Singapore
LESTROSO wrote:
...to click an image jpg and open the browser to google...

This should do it:
Code:
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!


Top
 Profile  
Reply with quote  
 Post subject: Re: how to open url webpage by clicking an image??
PostPosted: Fri Jun 07, 2019 6:36 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Nov 03, 2005 12:30 pm
Posts: 117
Location: Italy
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye