Silverfrost Forums

Welcome to our forums

Same button, many functions.

14 Mar 2014 10:01 #13835

G'day, folks 😄

Can ClearWin do this?

In a program such as Piriform's CCleaner the same button can assume many functions, according to the task selected.

For instance, without changing either its location or its appearance, it can successively denote 'Analyze', 'Cancel', 'Scan for issues', and 'Cancel scan'.

That certainly makes for very efficient use of window area, something I'd like to use in my programs. I was wondering if it's something that ClearWin could already achieve.

Eric

14 Mar 2014 10:36 #13836

Yes. You attach a callback function to the button. You need some mechanism to set a flag to indicate the response required then the callback can use the flag to carry out the selected task.

You can also change the text on the button depending on the flag by calling change_button_text@. For this you need to use %lc immediately after %bt or %bb or %tt.

15 Mar 2014 5:41 #13842

Quoted from PaulLaidler Yes. You attach a callback function to the button. You need some mechanism to set a flag to indicate the response required then the callback can use the flag to carry out the selected task.

You can also change the text on the button depending on the flag by calling change_button_text@. For this you need to use %lc immediately after %bt or %bb or %tt.

Thankyou 😃 Unfortunately I couldn't find any mention of the syntax for change_button_text@ in my manual's list of Library References (Chapter 27). The only 'change' items described are change_hypertext@ and change_pen@.

Thinking my manual could be out-of-date I checked at http://www.silverfrost.com/manuals/clearwin.pdf but couldn't find any mention there, either.

change_button_text@ sounds exactly what I need. Would you mind posting the syntax for this very useful operation? Thanks, in advance 😄

Eric

15 Mar 2014 6:07 #13843

Maybe this is what you are looking for: http://www.silverfrost.com/ftn95-help/clearwinp/library/change_button_text_.aspx

15 Mar 2014 7:17 #13844

At the risk of stating the obvious, you only get one callback function per button, and you need to keep a tally of which caption is on the button at any moment in time, and the callback has to address all possibilities.

The Windows User Interface Guidelines say 'Don't do it', but then Microsoft doesn't obey its own rules!

As well as the printed documentation, you also need to refer to FTN95.CHM, and one of my personal favourites for unexpected gems, the cwplus.enh file (in the docs folder of ftn95) - this gives a list of enhancements to Clearwin+ over many years. Read it and you'll discover lots of things!

Eddie

15 Mar 2014 7:22 #13845

Quoted from Wilfried Linder Maybe this is what you are looking for: http://www.silverfrost.com/ftn95-help/clearwinp/library/change_button_text_.aspx

Yes, that looks to be remarkably close to what I'm looking for 😄 Thankyou, Wilfried!

It also highlights that I need the Clearwin+ Users Guide, not just the manual.

Thanks again 😄

Eric

15 Mar 2014 7:28 #13846

Quoted from LitusSaxonicum

As well as the printed documentation, you also need to refer to FTN95.CHM, and one of my personal favourites for unexpected gems, the cwplus.enh file (in the docs folder of ftn95) - this gives a list of enhancements to Clearwin+ over many years. Read it and you'll discover lots of things! Eddie

Looks like I have a voyage of discovery ahead of me 😄 Many thanks, Eddie!

Eric

15 Mar 2014 8:17 #13847

An interesting footnote to the change_button_text discussion is that the compiler, or whatever, can 'sense' in advance what will be the longest text string.

It's my casual observation, post-discussion, that the button size (width) is unchanged as the length of the text string varies.

Eric

16 Mar 2014 8:43 #13849

Yes. When you change the button text dynamically, the button size will not change automatically. But there are functions to move the button and change its size.

The simplest way would be to compile using the button text that is longest and then change to the desired start up text using change_button_text@ within a %sc callback. The button will then be big enough for every case and the text will be automatically centred in the button.

16 Mar 2014 10:24 #13850

Thankyou 😄

Quoted from PaulLaidler ... But there are functions to move the button and change its size...

That reminds me of a 'survey' in which every choice (button) except one did a random jump to a new location whenever the mouse was hovered over it 😄

Seriously, though, consider a program which is compiled with the longest button text. Now, to be effective, where in relation to %bt should %sc be placed? %sc BEFORE %bt or %sc AFTER %bt

Eric

16 Mar 2014 12:10 #13851

Eric,

It doesn't matter, although for organisational reasons I usually start with anything to do with style, then follow with %sc and the variants of %cc (%cc and %`cc) before getting round to layout and controls. Indeed, I usually put all the 'style' format codes in a subroutine and call that immediately after %ca so that all my windows have common attributes which I get hold of in one line (although if you like lots of format codes in one line you do it as you see fit). My personal experience is that too many format codes in one line make the source look ugly and difficult to follow.

Also in my experience, different button styles (%bt, %tt, %bb etc) have different width-sizing rules, and some of them have bigger size jumps than others. If you want a lot all the same width you need to think carefully. One way to make %bt buttons all the same size is to specify the size on each e.g. %6bt and also make use of %ob[invisible] ... %cb to get them to line up vertically.

Eddie

17 Mar 2014 12:36 #13852

Quoted from LitusSaxonicum ... make the source look ugly and difficult to follow.

Thankyou Eddie 😄

The term 'self-documenting' comes to mind, but I get your point. It's important to remember that more than an inanimate compiler may want to understand what we've written.

Eric

Please login to reply.