It is currently Tue Jan 26, 2021 10:03 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Help please, stringgadget (or gadgets in general)
PostPosted: Wed Jun 15, 2005 4:27 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon May 16, 2005 9:37 pm
Posts: 436
Im trying to get it so if the string gadget is not being typed in, change it to my own variable, i cant think of how to check if its being typed in part, could someone point me in the right direction??


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Jun 15, 2005 4:45 pm 
Offline
Moderator
Moderator

Joined: Sat Dec 27, 2003 3:55 am
Posts: 3321
Location: Great Southern Land
Hi Hydrate.

Are you looking for something like this:
Code:
If GetGadgetText(#myStringGadget)=""
  SetGadgetText(#myStringGadget,"MY DEFAULT VALUE")
EndIf

Or a way to detect if the string was modded and not empty, eg, in your window loop:
Code:
Repeat
  EventID.l = WaitWindowEvent()
  If EventID = #PB_Event_CloseWindow
    Quit = #True
  ElseIf EventID = #PB_EventGadget
    widgetID=EventGadgetID()
    If widgetID=#myStringGadget
      If GetGadgetText(#myStringGadget)<>""
        myStringFlag.l=#True                    ; or whatever
      Else
        myStringFlag.l=#False                   ; or whatever
      EndIf
    EndIf
  EndIf
Until Quit = #True

Or something else entirely?

_________________
@}--`--,-- A rose by any other name ..


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Jun 15, 2005 5:31 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon May 16, 2005 9:37 pm
Posts: 436
Dare2 wrote:
Hi Hydrate.

Are you looking for something like this:
Code:
If GetGadgetText(#myStringGadget)=""
  SetGadgetText(#myStringGadget,"MY DEFAULT VALUE")
EndIf

Or a way to detect if the string was modded and not empty, eg, in your window loop:
Code:
Repeat
  EventID.l = WaitWindowEvent()
  If EventID = #PB_Event_CloseWindow
    Quit = #True
  ElseIf EventID = #PB_EventGadget
    widgetID=EventGadgetID()
    If widgetID=#myStringGadget
      If GetGadgetText(#myStringGadget)<>""
        myStringFlag.l=#True                    ; or whatever
      Else
        myStringFlag.l=#False                   ; or whatever
      EndIf
    EndIf
  EndIf
Until Quit = #True

Or something else entirely?


Im not too sure, il explain exactly what im trying to say in full, I am trying to make a simple web browser with purebasic, I have the string gadget to enter the text, i have the webgadget running ect, what i want is for when the web page loads a new page it will automatically change the adress bar, when its not then it will stay normal and you will be able to type in it and change the adress, so i used stringgadget for the text, and set it so if its different from the webgadgets text then change, but this meant i couldnt have the user type in it ect, so i was looking for basicly a code for if the user was not typing in the box then change to the webgadgets text.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Jun 15, 2005 5:40 pm 
Offline
Moderator
Moderator

Joined: Sat Dec 27, 2003 3:55 am
Posts: 3321
Location: Great Southern Land
Hi Hydrate.

In your PureBasic directory there is a subfolder Example\Sources which has a proggie called webBrowser.pb.

This gives a good example of what you are trying to achieve (and is far better than any quick code I type in here).

Hope it helps! :)

_________________
@}--`--,-- A rose by any other name ..


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Jun 15, 2005 5:49 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon May 16, 2005 9:37 pm
Posts: 436
Dare2 wrote:
Hi Hydrate.

In your PureBasic directory there is a subfolder Example\Sources which has a proggie called webBrowser.pb.

This gives a good example of what you are trying to achieve (and is far better than any quick code I type in here).

Hope it helps! :)


Thats what i used to start off, but say if you go too http://www.google.co.uk/ and search for "test search". The link then becomes http://www.google.co.uk/search?hl=en&q= ... arch&meta=

What i am trying to acheive is to have that link become that after the search, so basicly when the user is not typing in the adress bar i want it to update with the right link. It does not do that in the example you gave me or in any examples i can find, so i was wondering is it possible, and if it is how?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Jun 15, 2005 5:59 pm 
Offline
Moderator
Moderator

Joined: Sat Dec 27, 2003 3:55 am
Posts: 3321
Location: Great Southern Land
Added five lines to the eg which may do what you want.

Code:
;
; ------------------------------------------------------------
;
;   PureBasic - MiniBrowser
;
;    (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;
; This program requiers the Microsoft freely distribuable
; ATL.dll shared library.
;

Procedure ResizeWebWindow()
  ResizeGadget(10, -1, -1, WindowWidth(), WindowHeight()-52)
  ResizeGadget(4, -1, -1, WindowWidth()-185, -1)
  ResizeGadget(5, WindowWidth()-25, -1, -1, -1)
  ResizeGadget(6, -1, -1, WindowWidth(), -1)
EndProcedure


If OpenWindow(0, 100, 200, 500, 300, #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget, "PureBasic MiniBrowser v1.0")

  CreateStatusBar(0, WindowID())
    StatusBarText(0, 0, "Welcome to the world's smallest Browser ! :)", 0)
     
  CreateGadgetList(WindowID())
    ButtonGadget(1,   0, 0, 50, 25, "Back")
    ButtonGadget(2,  50, 0, 50, 25, "Next")
    ButtonGadget(3, 100, 0, 50, 25, "Stop")
 
    StringGadget(4, 155, 5, 0, 20, "http://www.purebasic.com")
   
    ButtonGadget(5, 0, 0, 25, 25, "Go")
   
    Frame3DGadget(6, 0, 30, 0, 2, "", 2) ; Nice little separator
 
    If WebGadget(10, 0, 31, 0, 0, "http://www.purebasic.com") = 0 : MessageRequester("Error", "ATL.dll not found", 0) : End : EndIf
 
  AddKeyboardShortcut(0, #PB_Shortcut_Return, 0)
 
  ResizeWebWindow()
  lasturl.s=GetGadgetText(10)          ; added this
  Repeat
    Event = WaitWindowEvent()

    If GetGadgetText(10)<>lasturl              ; added this
      lasturl=GetGadgetText(10)
      SetGadgetText(4,lasturl)
    EndIf                                                   ; up to here
   
    Select Event
      Case #PB_Event_Gadget
     
        Select EventGadgetID()
          Case 1
            SetGadgetState(10, #PB_Web_Back)
         
          Case 2
            SetGadgetState(10, #PB_Web_Forward)
         
          Case 3
            SetGadgetState(10, #PB_Web_Stop)
         
          Case 5
            SetGadgetText(10, GetGadgetText(4))
        EndSelect     
     
      Case #PB_Event_Menu ; We only have one shortcut
        SetGadgetText(10, GetGadgetText(4))

      Case #PB_Event_SizeWindow
        ResizeWebWindow()
     
    EndSelect
     
  Until Event = #PB_Event_CloseWindow
   
EndIf

Hope I am on track.

_________________
@}--`--,-- A rose by any other name ..


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Jun 15, 2005 6:03 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon May 16, 2005 9:37 pm
Posts: 436
Thats exactly what i was looking for, thank you.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: robertfern and 29 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