Help please, stringgadget (or gadgets in general)
Help please, stringgadget (or gadgets in general)
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??
Hi Hydrate.
Are you looking for something like this:
Or a way to detect if the string was modded and not empty, eg, in your window loop:
Or something else entirely?
Are you looking for something like this:
Code: Select all
If GetGadgetText(#myStringGadget)=""
SetGadgetText(#myStringGadget,"MY DEFAULT VALUE")
EndIf
Code: Select all
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
@}--`--,-- A rose by any other name ..
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.Dare2 wrote:Hi Hydrate.
Are you looking for something like this:Or a way to detect if the string was modded and not empty, eg, in your window loop:Code: Select all
If GetGadgetText(#myStringGadget)="" SetGadgetText(#myStringGadget,"MY DEFAULT VALUE") EndIf
Or something else entirely?Code: Select all
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
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=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!
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?
Added five lines to the eg which may do what you want.
Hope I am on track.
Code: Select all
;
; ------------------------------------------------------------
;
; 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
@}--`--,-- A rose by any other name ..