I am using the WP7 Tookit ListPicker (Feb release) on a Popup Control. I have trapped the Back button so I can close the popup.
If I press the back button while the ListPicker is open in popup mode, my back button event handler is firing before the ListPicker handles it so both the ListPicker and my popup are closing.
One way I thought of handling it was to check and see if I have any ListPickers on the popup that are open and if so close the and cancel the navigation (the controls on my popup are added dynamically so I have to enumerate through the popup child controls to check) but I can't find a way of seeing if the ListPicker is Open or Closing it.
So my question is a) is there a way of handling this in the back button handler and if not b) how can I check if a ListPicker is Open.
In your popup control's BackKeyPress callback add the following check:
if( myListPicker.ListPickerMode == ListPickerMode.Normal ) {
// Close popup
// Cancel navigation
e.Cancel = true;
}
When ListPickerMode is Expanded or Full the ListPicker will catch the back key pressed event and close itself.
EDIT:
According to #SteveChadbourne's comment the following worked:
if( myListPicker.ListPickerMode != ListPickerMode.Normal ) {
// Close the ListPicker
myListPicker.ListPickerMode = ListPickerMode.Normal;
// Cancel navigation
e.Cancel = true;
}
Related
I have a statusBarItem that I want to use to show the NSColorPanel.
The following code is called when the button is tapped, which activates the ColorPanel.
#IBAction func showColour( button:NSButton ){
DispatchQueue.main.async {
NSApplication.shared.orderFrontColorPanel(self)
print( "panel frame:\(NSColorPanel.shared.frame), is visible:\(NSColorPanel.shared.isVisible )" )
}
}
If the user presses the close button to close the colour panel, tapping the button to show the panel works as expected and displays the panel again. However, if the user clicks in an empty space, the colorPanel disappears, and tapping the button to reopen the panel does not work any more. However, based on the logs, it appears that the panel has a valid rect and is visible.
Any Suggestions?ThanksReza
As it was pointed out by a user on Reddit, when tapping in an empty space the app will go to the background, and is no longer the foreground application, so a utility-style window like the color panel will not be displayed. Hence as the app is not active, subsequent taps to show the colour panel, will not bring the utility window to the front.
So the solution is to make sure the app is active prior to trying to open the colour panel by calling:
NSApplication.shared.activate(ignoringOtherApps: true )
in the showColour function
I create a custom combobox that has a custom listbox. The default listbox of combobox is replaced by using this code:
m_comboBoxInfo.cbSize = sizeof(COMBOBOXINFO);
if (::GetComboBoxInfo(m_hWnd, &m_comboBoxInfo)){
m_ListBox.SubclassWindow(m_comboBoxInfo.hwndList);
}
I want the new drop-down list of the combobox is showed always, even if it loses focus or user clicks to other controls.
I tried to capture WM_CAPTURECHANGED and WM_KILLFOCUS at WindProc() function to do nothing.
LRESULT CCustomListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_CAPTURECHANGED ||
message == WM_KILLFOCUS){
return TRUE;
}
return CCustomListbox::WindowProc(message, wParam, lParam);
}
However, it not work. Could you please show me how to prevent closing dropdown listbox when it loses focus on.
My combobox looks like this.
I want the new drop-down list of the combobox is showed always, even if it loses focus or user clicks to other controls.
I want to make a combobox that its dropdown list is closed when the user clicks to the combobox button.
With these requirements, I would get rid of the combobox altogether and instead just combine an edit control, a button and a listbox. You would have full control over everything without having to fight against standard combobox logic. Even if you would get a "hack" working now, it is very likely to break in future Windows versions.
Simply toggle the listbox's show state when the button is pressed. React to selection change event of the listbox to update the text in the edit control.
I would group these controls in a parent control that at least has the WS_CHILD|WS_TABSTOP and WS_EX_CONTROLPARENT window styles set. The latter is important to enable keyboard navigation into and out of the child controls as if the parent control doesn't exist. The "group" control will also encapsulate the notifications from the button and list control (as these are implementation details not intended for the parent of the group control).
You could even emulate notification messages of a regular combobox by sending WM_COMMAND messages to the parent of your "group" control.
I want to make a program (program 1) that will click a toolbar button on another program (program 2). I have the handle of the window the toolbar button is in and I have its button ID. At first I thought I could use the function:
SendMessage (buttonHandle, BN_CLICK, 0, 0);
but I have no clue as to how to get the handle of the tool bar button. I tried to use the function:
GetDlgItem ( windowHandle, buttonID);
but it doesn't work. I also have been told that since it's a toolbar button, there is no specific handle for it... kind of odd, not sure how that works...
Question 1:: is there a handle for toolbar buttons and how may I get it?
Question 2 (MAIN AND MOST IMPORTANT QUESTION!):: what function can I use to click on a toolbar button? (please mention the parameters for the function too)
Is there a handle for toolbar buttons and how may I get it?
No. Toolbar buttons are non-windowed. They do not have window handles.
What function can I use to click on a toolbar button?
You use UI Automation to automate other applications.
Ok I write Windows Phone 7.5 application in which I have several textboxes in a single page.
I made a ScrollViewer and inside I have a Grid and the textBoxes are inside the Grid.
I want to make it so that when I press enter keyboard button in the textbox I will focus on the next textBox.
So I made events in which I check whether enter button is clicked and if it is I focus on the next element, but when I focus on textBox which is even lower than the normal window and you have to scroll down to see it, it actually focuses on it but doesn't displays it and the screen stays on the last marked textbox.
Is there a way to fix that? Here is how I do it:
private void txtUsername_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
txtPassword.Focus();
}
}
I have a dialog window that can be cancelled through a custom Cancel button or using the system red window button. I need to perform some simple logic when the dialog is cancelled. How do I detect that the user has pressed the red button?
I know I can detect the window being closed using the -windowWillClose: delegate callback. But this callback is also called when I close the window programmatically after the dialog succeeds. I also know I could simply set up a BOOL flag, but is there a better solution? It would be best if I could detect the red button activation.
Define close button:
NSButton *closeButton = [self standardWindowButton:NSWindowCloseButton];
Connect close button to custom selector:
[closeButton setTarget:self.delegate];
[closeButton setAction:#selector(closeThisWindow)];
Run specific code and close window manually.
-(void)closeThisWindow {
//
// The NSWindowCloseButton has been clicked.
// Code to be run before the window closes.
//
[self close];
}