Watching the InputScope of a TextBox? - windows-phone-7

How do we grab the event that is generated when the inputscope of a TextBox is set to search and the Arrow is pressed?

1.There is an event OnKeyDown where you can check what key is pressed
textBox.OnKeyDown += (s, e) =>
{
if (e.Key == Key.Enter)
{
// perform search
e.Handler = true;
}
}
2.ScrollViewer automatically scrolls to focused textbox, I guess...

Related

Xamarin - How to know what has been clicked in collection view?

I have a CollectionView with an image and a button in it. I use following code to see if somebody pressed anywhere within the cell:
private void CollectionView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (((CollectionView)sender).SelectedItem != null)
{
var item = (picdata)e.CurrentSelection.FirstOrDefault();
((CollectionView)sender).SelectedItem = null;
if (allowfullscreen == "1" || allowfullscreen == "true")
{
Navigation.PushAsync(new Picture());
}
}
}
But how can I know if he clicked the button inside the cell? I was trying to do it via the Click event, but then I do not know which one of all the buttons has been clicked.
you can get the item from the BindingContext of the sender
var item = (picdata)(Button)sender.BindingContext;

JavaFX: Right click on Mac (Control + Click) not being detected. Any fixes?

I have a list view with items that I am allowing to be double clicked and right clicked (to delete the item). Why does control clicking not work on a mac? Thanks in advance.
Edit: My code is
listview.setOnMouseClicked(new EventHandler<MouseEvent>()
{
#Override
public void handle(MouseEvent event)
{
if (event.getButton().equals(MouseButton.PRIMARY))
{
if (event.getClickCount() == 2)
{
System.out.println("Double clicked");
System.out.println("clicked on " + listview.getSelectionModel().getSelectedItem());
}
}
if(event.getButton().equals(MouseButton.SECONDARY))
{
System.out.println("Right click");
}
}
});
My trackpad is set up as secondary button with two finger tap.
For anyone else looking this up. It is correct that two finger clicking will register as a MouseButton.SECONDARY event, but I think you should also check for Ctrl + MouseButton.PRIMARY since holding the control key is a common method for emulating a right click. So the if statement should be :
if ( event.getButton() == MouseButton.SECONDARY || e.isControlDown() ) {
// DO RIGHT CLICK ACTION
}

How to detect shift down when clicking on ScriptUI button?

On my scriptUI panel, I have a button. How can I detect whether the user is holding the shift key when they click on the button?
You can add an eventListener to your button.
var win = new Window ("dialog");
win.aButton = win.add ("button", undefined, "Button");
win.aButton.addEventListener ("click", function (k) {
if (k.shiftKey) {
alert("foo");
}else{
alert("bah");
}
});
win.show ();

TextBox Leave Event suppresses Button Click

I have a simple Windows Form: 'Message' TextBox has Enter and Leave events to allow user to enter text in another language only on that field. 'Send' button sends the form content. After the user fills the Message and clicks Send, Textbox's Leave event prevent button's Click event from firing. I need both handlers to run.
Here's the relevant code:
private void Message_Enter(object sender, EventArgs e)
{
inputLang = InputLanguage.CurrentInputLanguage;
foreach (InputLanguage lang in InputLanguage.InstalledInputLanguages)
{
if (lang.LayoutName == "United States-International")
{
InputLanguage.CurrentInputLanguage = lang;
break;
}
}
}
private void Message_Leave(object sender, EventArgs e)
{
InputLanguage.CurrentInputLanguage = inputLang;
}
private void Send_Click(object sender, EventArgs e)
{
string dest = ServerList.Text;
string msg = Message.Text;
if (dest.Length == 0 || msg.Length == 0 )
{
Log("Fill the destination server and the message");
return;
}
if (context.SendMessage(dest, msg))
{
if (!ServerList.Items.Contains(dest))
{
ServerList.Items.Add(dest);
}
}
else
{
if (ServerList.Items.Contains(dest))
{
ServerList.Items.Remove(dest);
}
}
}
The problem is now solved. The problem is caused by the change of input language. If the enter and leave handlers did other stuff then the click event will fire normally. Since I need to change the input language I solved it by monitoring the MouseDown, MouseClick and MouseUp events and generating a click if it was not automatically generated.
I've got same problem. When I changed the input language and then on leave event set it back to default one. When i click on other component it wont fire click event. I had to click twice then.
I thing it has something to do with focus.
I solved it by setting the focus back to form, after changing back the input language.
Here is the handler:
void textBoxSearch_LostFocus(object sender, EventArgs e)
{
InputLanguage.CurrentInputLanguage = InputLanguage.DefaultInputLanguage;
this.Focus();
}
Hope it helps...

Wp7 Camera Button Event

Within a Windows Phone 7 app, is it possible to capture the hardware camera button pressed event in code?
Right now when I press the camera button nothing happens and I can't figure out how to hook up to the event.
Yes you can. Check this link. This is an example of the events:
// The event is fired when the shutter button receives a half press.
CameraButtons.ShutterKeyHalfPressed += OnButtonHalfPress;
// The event is fired when the shutter button receives a full press.
CameraButtons.ShutterKeyPressed += OnButtonFullPress;
// The event is fired when the shutter button is released.
CameraButtons.ShutterKeyReleased += OnButtonRelease;
// Provide auto-focus with a half button press using the hardware shutter button.
private void OnButtonHalfPress(object sender, EventArgs e)
{
if (cam != null)
{
// Focus when a capture is not in progress.
try
{
this.Dispatcher.BeginInvoke(delegate()
{
txtDebug.Text = "Half Button Press: Auto Focus";
});
cam.Focus();
}
catch (Exception focusError)
{
// Cannot focus when a capture is in progress.
this.Dispatcher.BeginInvoke(delegate()
{
txtDebug.Text = focusError.Message;
});
}
}
}

Resources