Checked Toggle between TMenuItems in group - delphi

I have three menu items I would like to toggle between one another with a check.
The first one is default checked = true and the other two are false
I would like to have the check mark show next to the one clicked
I tried setting the group index of the three different from the rest of all the other menu items, but that didn't seem to work. All three menu items have autocheck = true
do I have to manually handle all this by code?
thanx

You need to do the following for each of the three menu items:
Set AutoCheck to True.
Set RadioItem to True.
Set the GroupIndex for all three items to the same value.
This will result in a bullet rather than a tick being placed next to your menu item. That's by design. These menu items operate like radio buttons (hence the bullet) rather than check boxes (which would have ticks).

Related

TComboBox.AutoCloseUp Property: What does it do?

From the documentations:
Specifies whether the drop-down closes up automatically when the user
selects an item.
I have played with this property (combined with AutoComplete and AutoDropDown) and I just can't seem to figure out the UI behavior of this property.
Setting it to True or False I can't see any difference in how it behaves.
Can anyone explain to me what it does exactly?
You will see the difference if you have AutoCloseUp = True and also AutoDropDown = True. For example, if you have items '0', '1' and '2' and the ComoBox has focus, when you use the keyboard and press 2 the dropdown list flashes briefly and is closed again with item '2' selected. If you change AutoCloseUp = False, then the dropdownlist remains open (and you can change your selection with the arrow keys) until you indicate your selection with Enter
If you operate the combo only with your mouse, then there's no difference.
Addition after comments
If you add to my example items '22' and 'more' and you also have AutoComplete = True (which it is by default) you will note the following:
item '22' is not selectable with two consecutive hits on 2. It is of course still selectable with the arrow keys, like all other items.
The AutoCloseUp feature closes the dropdown when AutoComplete finds a matching item for all sofar typed keys. If you type m, o, r the list is still open, 'more' selected and the list is finally closed if you type the missing e.

AllowAllUp property for TToolButton Is Not Working

I am using Delphi XE5.
I am trying to workout as per the Delphi's help about TToolButton component.
Delphi Help Says about TToolButton.AllowAllUp property:
Indicates whether all the tool buttons in a group can be un-selected at the same time.
If AllowAllUp is set to true, all of the tool buttons in the group can be unselected. If AllowAllUp is set to false, at least one tool button in the group must be selected at any time. (Determine which tool button is initially selected by setting its Down property to true.)
AllowAllUp is effective only when Grouped is true and Style is set to tbsCheck. Changing the value of AllowAllUp for one button in a group automatically changes the value for all buttons in the group.
What I have done is I have placed a TToolBar on the form and created three TToolButtons in it. Then AllowAllUp and Grouped property is set to True. Also, set Style property to tbsCheck.
When I run the application, and when I go on clicking all buttons one by one, then any one button is showing as selected, if i try to select or click on other TToolButton previous one becomes un-selected.
How to make AllowAllUp property working?
These properties all work as intended. It seems that you are misunderstanding the intent of these properties.
The documentation for the Grouped property says:
When an unbroken sequence of adjacent tool buttons each has its Grouped property set to true and Style set to tbsCheck, then no more than one of the buttons can be selected at the same time.
The AllowAllUp property is related and described like so:
Indicates whether all the tool buttons in a group can be unselected at
the same time.
If AllowAllUp is set to true, all of the tool buttons in the group can
be unselected. If AllowAllUp is set to false, at least one tool button
in the group must be selected at any time. (Determine which tool
button is initially selected by setting its Down property to true.)
AllowAllUp is effective only when Grouped is true and Style is set to
tbsCheck. Changing the value of AllowAllUp for one button in a group
automatically changes the value for all buttons in the group.
This property only has an impact when you group buttons, and what it does is control whether or not you can have zero buttons down. But once you have grouped buttons, never more than one of the group can be down at any one time.
You need to do the following:
Set Grouped to False.
Set AllowAllUp to False, not that it really matters but you may as well restore the default to avoid confusion.
Set the style to tbsCheck.
Once you've done this you can check and uncheck the buttons independently of each other.

In TButtonGroup.ButtonOptions what does adding gboGroupStyle do?

The help indicates that adding gboGroupStyle to the ButtonOptions on a TButtonGroup:
"Specifies that the buttons should inherit the group style that is set on the container."
But this explanation still leaves me lost - any ideas?
The gboGroupStyle option in the TButtonGroup.ButtonOptions property has nothing to do with GroupIndex as it's known e.g. from TSpeedButton.
Setting of the gboGroupStyle option to True allows you to:
set the TButtonGroup.ItemIndex property, so you can predefine which button will be focused as default, nothing cool
click the buttons with ENTER or SPACE keys, what will fire the TGrpButtonItem.OnClick event of the button item (if assigned), perform its action, or fire the TButtonGroup.OnButtonClicked event
I agree the name of this is quite misleading, but that's what I found in the source code from Delphi-XE2.
gboGroupStyle makes the TButtonGroup act as a group - that means, one and only one button is selected at a given time. It is similar to grouping several TSpeedButtons with the GroupIndex, where only one button inside that group is selected at any time. The currently selected button can be read and written via the ItemIndex property of TButtonGroup. To visualize the selected button one can implement an OnBeforeDrawButton or OnDrawButton handler.
From my experimentation it looks like if gboGroupStyle is used then the ItemIndex property can be set to something other than -1, so that the TButtonGroup remembers the last button that was pressed.

How do I move multiple nodes at once in a TJvTreeView?

When you select multiple nodes of a JvTreeView, and then try to drag these nodes, the JvTreeView selects the node you clicked to drag, rather than initiating dragging all the selected nodes. You end up dragging only this single node.
Is it possible to drag multiple nodes in a JvTreeView? I am using Delphi 2007.
UPDATE: Oddly enough, if I hold down CTRL+SHIFT when dragging the items, I can successfully drag them all. Any ideas?
Suppose MultiSelectStyle is the default [msControlSelect], then the answer to your question is 'you don't release the control key when you're selecting the last item and beginning dragging'.
The culprit is in TJvTreeView.WMLButtonDown in JvComCtrls.pas. Code there tests if 'Ctrl' is pressed when the TreeView is MultiSelect, and clears all items and selects the clicked item if 'Ctrl' is not pressed. It should instead test if the clicked item is already selected and do nothing if it is.
You can see the broken behavior without dragging. Multi select a few items and then click a selected item with the mouse. The VCL TreeView do not select or de-select anything, while the JVTreeView, instead, de-selects all items and selects the clicked one.
Yes absolutely, I do it all the time.
Of course Multi-Select needs to be True and you may need to have a look at the TTreeView's MultiSelectStyle. That controls what type of nodes can be selected at the same time. For example if msSiblingOnly is set to true, you can only select sibblings.
Are you using dmAutomatic or dmManual. If the latter, it could be that you are doing something in the OnMouse* events that is negating the multi-selection you made earlier.

Ribbon buttons act like a group

I created 3 actions and assigned them to 3 buttons in a ribbon group. I want the buttons act like a group, one is always down, the others - up. Just like left/center/right align buttons.
I have set groupIndex property of my actions to 1. Help says:
"GroupIndex is used to define groups of actions that act like radio buttons. When GroupIndex is greater than 0, it identifies the group to which the action belongs. When the Checked property of any action in that group is set to true, the Checked property of all other actions in the group is set to false. That is, only one action in the group can be checked at a time."
But it is not working at all.
Any help?
Try to set the property AutoCheck = true for both items. It helped me =)
Without more information the only thing I can suggest is (if you are using tdxRibbon) is to check and make sure the buttonstyle property is set to bsChecked. Although it shouldn't let you set the group index otherwise.

Resources