How to add shadow to menu drop-down list? - menu

In a menu bar, when we click a menu, there is a menu drop-down list containing some menu items. My question is how to add shadow to the menu drop-down list? Just like I see there is shadow in the combo box drop-down list in the default javafx implementation. Thanks ~

yourDropDownMenu.setEffect(addLabelEffect());
Define the drop shadow in the controller class and check if its working. Here is a simple sample
private DropShadow addLabelEffect() {
DropShadow ds = new DropShadow();
ds.setSpread(0);
ds.setOffsetY(1.0);
ds.setOffsetX(1.0);
ds.setColor(Color.BLACK);
return ds;
}

Related

How to provide dropdown submenus inside one tray menu as below shown in image using pystray library in python?

Here is my sample code:
image = Image.open("E:\\production\\Windows utility tool\\images\\icon.ico")
menu = (item("Sign in", show_window), item("Change status", status_online), item("Change icon", change_icon), item("Open application", open_application), item("Quit", quit_window))
icon = pystray.Icon("Notifer", image, "notifier_application", menu)
icon.run()
See sample image
This is how the menu should be for drop down submenus
menu = (
Item('mainitem1', callable),
Item('mainitem2', callable),
Item('mainitem3', Menu(Item('subitem1', callable),Item('subitem2', callable))),
Item('mainitem4', callable)
)
Make sure to add from pystray import Menu, MenuItem as Item at the beginning of the code.
Hope I gave you a proper answer.

How to click one of the options listed in the drop down menu in hand coded UI testing?

UITestControl uiLinkAboutus = new UITestControl(_bw);
uiLinkAboutus.TechnologyName = "Web";
uiLinkAboutus.SearchProperties.Add("ControlType", "Image");
uiLinkAboutus.SearchProperties.Add("TagName", "IMG");
uiLinkAboutus.SearchProperties.Add("Alt", "Open Menu");
Mouse.Click(uiLinkAboutus);
/* Upon execution, the drop down button is clicked but the option listed below is not clicked. How to solve this problem?
In stead of searching for an image, search for the list or dropdown control using a wpfCombobox, winCombobox or HtmlComboBox control. There you set the selectedItem property to the value you want. that is the most robust way of selecting an item in the UI. so e.g. :
ApplicationUnderTest aut = ApplicationUnderTest.Launch(#"yourapp.exe");  
WpfComboBox cbBox = new WpfComboBox(aut);
cbBox.SearchProperties.Add(WpfComboBox.PropertyNames.AutomationId,"cmbCountries");//AutomationId == xName roperty
cbBox.SelectedItem = "your value";

MFC ComboBox dropdown list too short

I have dropped ComboBox on dialog form. Also I have added some text to it:
BOOL CMyAppDlg::OnInitDialog()
{
CComboBox *combo= (CComboBox *)GetDlgItem(IDC_COMBO_TT);
combo->AddString("s1");
combo->AddString("s2");
//...
return TRUE;
}
When I drop down ComboBox it shows only one selection line and adds arrows to select other items. How to increase dropdown size?
Click the combo button in dialog editor. You can now drag down to set the open size.

Disable Custom Context Menu items in PyQt

So I created a custom context menu, but I want to grey out some of the items in certain rows of my tree widget depending on certain values. How do I disable items on the menu?
myUI.setContextMenuPolicy( Qt.CustomContextMenu )
myMenu = QMenu( "Right Click Menu", myUI )
action = myMenu.addAction( "Item 1" )
action.triggered.connect( someFunction )
To disable a menu item, just disable the QAction
action.setEnabled(False)

C# TableLayoutPanel replace control?

I was wondering if it was possible to replace one control in a TableLayoutPanel with another at runtime. I have a combo box and a button which are dynamically added to the TableLayoutPanel at runtime, and when the user selects an item in the combo box and hits the button, I'd like to replace the combobox with a label containing the text of the selected combo box item.
Basically, if I could simply remove the control and insert another at it's index, that would work for me. However I don't see an option like "splice" or "insert" on the Controls collection of the TableLayoutPanel, and I was wondering if there was a simple way to insert a control at a specific index. Thanks in advance.
Fixed this by populating a panel with the two controls I wanted to swap and putting that into the TableLayoutPanel. Then I set their visibility according to which I wanted to see at what time.
This is what I've been able to come up with for what I needed. It gets the position of the ComboBox and makes a new label using the selected value.
// Replaces a drop down menu with a label of the same value
private void lockDropMenu(ComboBox dropControl)
{
TableLayoutPanelCellPosition pos = myTable.GetCellPosition(dropControl);
Label lblValue = new Label();
myTable.Controls.Remove(dropControl);
if (dropControl.SelectedItem != null)
{
lblValue.Text = dropControl.SelectedItem.ToString();
lblValue.Font = lblValue.Font = dropControl.Font;
// Just my preferred formatting
lblValue.AutoSize = true;
lblValue.Dock = System.Windows.Forms.DockStyle.Fill;
lblValue.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
myTable.Controls.Add(lblValue, pos.Column, pos.Row);
}
}

Resources