Page 1 of 1
How do I get id of a statusbartext?
Posted: Wed Jan 08, 2014 8:20 am
by garretthylltun
I tried a search but found nothing, or I didn't search for the right terms.
I would like to disable/enable specific StatusBarText items, but either it's not possible or I'm doing it wrong. I've tried doing the following to get the id:
Code: Select all
StatusText1.s=GadgetID(StatusBarText(0,1))
Any pointers appreciated.
Thanks,
~Garrett
Re: How do I get id of a statusbartext?
Posted: Wed Jan 08, 2014 8:34 am
by skywalk
Re: How do I get id of a statusbartext?
Posted: Wed Jan 08, 2014 9:51 am
by Shardik
For Windows
this code example demonstrates how to display a StatusBarField as seemingly disabled.
The following code example (Windows only) demonstrates how to change the text of a StatusBarField:
Code: Select all
OpenWindow(0, 200, 100, 300, 80, "StatusBar demo")
ButtonGadget(0, 55, 20, 180, 20, "Change text in 2nd StatusBarField")
If CreateStatusBar(0, WindowID(0))
AddStatusBarField(100)
AddStatusBarField(100)
AddStatusBarField(#PB_Ignore)
EndIf
StatusBarText(0, 0, "Info 1")
StatusBarText(0, 1, "Info 2")
StatusBarText(0, 2, "Info 3")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0 And EventType() = #PB_EventType_LeftClick
SendMessage_(StatusBarID(0), #SB_SETTEXT, 1, @"Info 2 changed!")
DisableGadget(0, #True)
EndIf
EndSelect
ForEver
Re: How do I get id of a statusbartext?
Posted: Wed Jan 08, 2014 12:45 pm
by em_uk
Why didn't you just check the help? It's right there.
The PB team have spent a great deal of time making it as complete as can be so use it!

Re: How do I get id of a statusbartext?
Posted: Wed Jan 08, 2014 1:04 pm
by Shardik
em_uk wrote:Why didn't you just check the help? It's right there.
The PB team have spent a great deal of time making it as complete as can be so use it!

Sorry, but where does the StatusBar help describe how to solve the problem of the original poster: to disable or enable a StatusBarField containing text (this is only possible with a callback using API functions or as an alternative demonstrated by RASHAD with overdrawing the text in the StatusBarField using graphics functions) or how to get the ID of a StatusBarField containing text (not the ID of the StatusBar)? It's only possible to read/change the text of a StatusBarField by using API funktions, hence my code example...

Re: How do I get id of a statusbartext?
Posted: Wed Jan 08, 2014 1:12 pm
by PB
> where does the StatusBar help describe how to solve
> the problem of the original poster
They're replying to the topic's subject: "How do I get ID..."

Re: How do I get id of a statusbartext?
Posted: Wed Jan 08, 2014 4:07 pm
by Demivec
Shardik wrote:It's only possible to read/change the text of a StatusBarField by using API funktions, hence my code example...

Here's your example code that has been changed so it should be cross-platform, without using API functions, by following the information from the Manual for StatusBar.
Code: Select all
OpenWindow(0, 200, 100, 300, 80, "StatusBar demo")
ButtonGadget(0, 55, 20, 180, 20, "Change text in 2nd StatusBarField")
If CreateStatusBar(0, WindowID(0))
AddStatusBarField(100)
AddStatusBarField(100)
AddStatusBarField(#PB_Ignore)
EndIf
StatusBarText(0, 0, "Info 1")
StatusBarText(0, 1, "Info 2")
StatusBarText(0, 2, "Info 3")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0 And EventType() = #PB_EventType_LeftClick
StatusBarText(0, 1, "Info 2 changed!")
DisableGadget(0, #True)
EndIf
EndSelect
ForEver
Re: How do I get id of a statusbartext?
Posted: Wed Jan 08, 2014 4:57 pm
by Shardik
Demivec wrote:Here's your example code that has been changed so it should be cross-platform, without using API functions, by following the information from the Manual for StatusBar.
Thank you for opening my eyes, Demivec...

I simply didn't understand that it's possible to change the text of a StatusBarField. I thought that it's only possible to define the text once...
Now please also show me how to disable the text of a StatusBarField according to the manual...

Re: How do I get id of a statusbartext?
Posted: Wed Jan 08, 2014 5:51 pm
by Demivec
Shardik wrote:Now please also show me how to disable the text of a StatusBarField according to the manual...

Status bars become disabled when you don't update them anymore. As RASHAD showed you can simply replace a text field with an image showing whatever you want, in his example it was gray text.
IMHO the limitation is on determining the colors for an OS that indicate something is disabled. This is not a limitation on the functionality of the StatusBar in PureBasic.

Re: How do I get id of a statusbartext?
Posted: Wed Jan 08, 2014 6:19 pm
by skywalk
Shardik wrote:I simply didn't understand that it's possible to change the text of a StatusBarField. I thought that it's only possible to define the text once...
It is called a
StatusBarField so you can update it more than once.
But, I do have to use a callback and api calls to respond to user MouseClicks.
Re: How do I get id of a statusbartext?
Posted: Wed Jan 08, 2014 7:50 pm
by garretthylltun
I do apologize if I caused any confusion or failed to find the info on my own.
I thought I could use DisableGadget() if I had the ID of the specific field in the StatusBar. But I was unable to find anything in the Help File or via search here on the forums. I saw StatusBarID() but that only gets me the ID of the StatusBar and not any individual field within the StatusBar.
My goal was to set 1 of 3 fields to disable or enabled based on CAPS, NUM and SCROLL for a little notes program. Typically these are in the status bar and are either Enabled or Disabled based on whether those keys are active or inactive.
I do not see in the help file where I can get the ID of any StatusBarText, only the StatusBar... If I am missing something, could someone please tell me what in the help file explains this to me?
And to those who say that the PB team has better things to do... What is the point of the forums then? I thought the forums were here for users to get help from one another, am I incorrect? Did I post this in the wrong section? If so, I do apologize.
P.S. I spent near 2 hours trying to figure this out, searching the help file, trying various keywords and keyword combinations on the search of the forums. I might be old and absent minded at times but I am not an idiot.. I just could not find the answers.
Re: How do I get id of a statusbartext?
Posted: Wed Jan 08, 2014 8:03 pm
by garretthylltun
Thank you Shardik.. That may be exactly what I was looking for.
It's obvious now that what I was looking for is not a built-in feature and someone had to come up with a work-around... So, The help file would not have specifically helped. I'd like to see someone try to find this answer under "StatusBar Manual..."
Thanks to those who offered help. It really is appreciated,
~Garrett
Could a Mod plz move this thread to it's appropriate section. Thx