Drop-down menu button with "sticky option"?

Hello Community,

With the kind of buttons that have multiple drop-down options: are these buttons designed such that they generally cycle through all available options on each button press?

I'm referring to the flat view button that has four dropdown options for different flat view modes.

Can the button be configured such that it remembers the last drop-down option that has been used? At the moment, it seems that the button cycles through all available options on each button press.

I normally only use Flat View Mixed (No Folders) and only occasionally Mixed (i.e. with folders). Is such "sticky" behavior possible with the current button, or will I have to create some kind of custom button to act like this?

A button with this code:

Set FLATVIEW=Toggle

will toggle between off and the most recently used options.

Or you can use a menu button that combines the toggeling and the list:

Flat View.dcf (1.7 KB)

Not sure if I understand correctly. This button only seems to toggle one of the multiple versions of Flat View on and off, or doesn't it?

I don't think you can cycle through Flatview like you can through View but you can easily build your own cycling button, e.g.:

@if:Set FLATVIEW=off
Set FLATVIEW=Mixed

@if:Set FLATVIEW=Mixed
Set FLATVIEW=MixedNoFolders

@if:Set FLATVIEW=MixedNoFolders
Set FLATVIEW=off

If you use one mode much more often than the other a modifier key might be better, e.g.:

@if:Set FLATVIEW=off
Set FLATVIEW=Mixed{=KeyDown("ctrl") ? "" : "NoFolders"=}

@if:else
Set FLATVIEW=off
1 Like

Thanks very much. However, I believe that the standard Flat View button does already cycle through all available Flat View modes on each button press:

I am trying to build a button that doesn't cycle but remembers the last used Flat View mode?

The standard button also includes

Set FLATVIEW=Grouped

so that's one more :slight_smile:

This can be achieved using an OnFlatViewChange event. When the flat view is turned off, the event stores the flat view mode in a variable. This allows the button to determine which flat view to open the next time.

1 Like

Phew. This seems to go a little over my head :face_in_clouds:

Is there a ready-made button available somewhere? Alternatively, what would I have to input into the button dialog to make this work?

Does it have to be a single button?

How would you distinguish between turning flat view on/off and switching modes?

I'd think with a long press, same as the default button does?:

Ah, yes, I forgot how the original button worked :blush:


We can get away without an event :+1:

Let's modify each of the three sub-buttons like so:

Set FLATVIEW=On,Grouped
@set glob!:prefFlatView=On,Grouped

to store the selected mode and the main button like so:

@if:Set FLATVIEW=On
Set FLATVIEW=Off

@if:else
Set FLATVIEW={=Val("$glob:prefFlatView") == "" ? "on" : Val("$glob:prefFlatView")=}

to recall a memorized setting.

Get the complete drop-down button here:

XML
<?xml version="1.0"?>
<button backcol="none" display="icon" label_pos="right" no_label="yes" textcol="none" timed="yes" type="menu_button">
	<label>&amp;Flat View</label>
	<tip>Displays the contents of all sub-folders in the current file display</tip>
	<icon1>#flatviewgrouped</icon1>
	<function type="normal">
		<instruction>@toggle:if Set FLATVIEW=Toggle</instruction>
		<instruction>@icon:flatviewmixed,Set FLATVIEW=Mixed</instruction>
		<instruction>@icon:flatviewmixednofolders,Set FLATVIEW=MixedNoFolders</instruction>
		<instruction />
		<instruction>@if:Set FLATVIEW=On</instruction>
		<instruction>Set FLATVIEW=Off</instruction>
		<instruction />
		<instruction>@if:else</instruction>
		<instruction>Set FLATVIEW={=Val(&quot;$glob:prefFlatView&quot;) == &quot;&quot; ? &quot;on&quot; : Val(&quot;$glob:prefFlatView&quot;)=}</instruction>
	</function>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>&amp;Grouped</label>
		<tip>Displays the contents of all sub-folders in the current file display (grouped by location)</tip>
		<icon1>#flatviewgrouped</icon1>
		<function type="normal">
			<instruction>Set FLATVIEW=On,Grouped</instruction>
			<instruction>@set glob!:prefFlatView=On,Grouped</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>&amp;Mixed</label>
		<tip>Displays the contents of all sub-folders in the current file display</tip>
		<icon1>#flatviewmixed</icon1>
		<function type="normal">
			<instruction>Set FLATVIEW=On,Mixed</instruction>
			<instruction>@set glob!:prefFlatView=On,Mixed</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" separate="yes" textcol="none">
		<label>M&amp;ixed (No Folders)</label>
		<tip>Displays the contents of all sub-folders in the current file display (but hides the folders themselves)</tip>
		<icon1>#flatviewmixednofolders</icon1>
		<function type="normal">
			<instruction>Set FLATVIEW=On,MixedNoFolders</instruction>
			<instruction>@set glob!:prefFlatView=On,MixedNoFolders</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>&amp;Off</label>
		<tip>Turns Flat View off and returns the folder display to normal</tip>
		<icon1>#flatviewoff</icon1>
		<function type="normal">
			<instruction>Set FLATVIEW=Off</instruction>
		</function>
	</button>
</button>
1 Like

Wow thank you, that's a total awesome button, which I believe should be included by default!

Now I only have a small (related) issue, not with the button, but with Flat View Mixed (files and folders).

If I filter a mixed flat view, only files are filtered but not folders, although "Files and Folders" are set in the option settings of the filter box:

Dopus File Filter Box

Might be this setting:

Enable filtering out of sub-folders in Flat View. By default the quick filter (i.e. the filter set by the Filter Bar) is not applied to folders when the file display is in Flat View. The reason for this is that when a folder is filtered from the list, all its contents are automatically filtered as well, and this may lead to undesired results. The Filter Bar has a checkbox option displayed when the file display is in Flat View mode that lets you turn folder filtering on or off, and you can use this option to control the default state of that checkbox (that is, if you normally do want the quick view filter to apply to folders as well as files in Flat View, turn this option on.)

flatview_folder_filters

See also here.

Otherwise, I'd rather start a new thread.

1 Like

Thanks! Other than I thought, that seems to be a rather complex issue.

Yes I will start a new thread on occasion.