public override void editString(global::com.codename1.ui.Component n1, int n2, int n3, global::java.lang.String n4, int n5) { using (AutoResetEvent are = new AutoResetEvent(false)) { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { textInputInstance.Text = toCSharp(n4); textInputInstance.IsEnabled = true; currentlyEditing = (com.codename1.ui.TextArea)n1; com.codename1.ui.Font fnt = (com.codename1.ui.Font)((com.codename1.ui.plaf.Style)currentlyEditing.getStyle()).getFont(); XNAFont font = (XNAFont)fnt.getNativeFont(); if(font == null) { font = defaultFont; } font.applyFont(textInputInstance); textInputInstance.Height = currentlyEditing.getHeight(); textInputInstance.Width = currentlyEditing.getWidth(); textInputInstance.Margin = new Thickness(0); textInputInstance.AcceptsReturn = !currentlyEditing.isSingleLineTextArea(); textInputInstance.Focus(); }); } com.codename1.ui.Display d = (com.codename1.ui.Display)com.codename1.ui.Display.getInstance(); d.invokeAndBlock(new WaitForEdit()); using (AutoResetEvent are = new AutoResetEvent(false)) { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { textInputInstance.IsEnabled = false; app.Focus(); }); } }
public override void editString(global::com.codename1.ui.Component n1, int n2, int n3, global::java.lang.String n4, int n5) { com.codename1.ui.Display d = (com.codename1.ui.Display)com.codename1.ui.Display.getInstance(); if (textInputInstance != null) { commitEditing(); d.callSerially(new EditString(n1, n2, n3, n4, n5)); return; } currentlyEditing = (com.codename1.ui.TextArea)n1; using (AutoResetEvent are = new AutoResetEvent(false)) { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { textInputInstance = new TextBox(); textInputInstance.TextChanged += textChangedEvent; cl.Children.Add(textInputInstance); Canvas.SetZIndex(textInputInstance, 50000); textInputInstance.Text = toCSharp(n4); textInputInstance.IsEnabled = true; com.codename1.ui.Font fnt = (com.codename1.ui.Font)((com.codename1.ui.plaf.Style)currentlyEditing.getStyle()).getFont(); NativeFont font = f((java.lang.Object)fnt.getNativeFont()); // workaround forsome weird unspecified margin that appears around the text box Canvas.SetTop(textInputInstance, currentlyEditing.getAbsoluteY() - 10); Canvas.SetLeft(textInputInstance, currentlyEditing.getAbsoluteX() - 10); textInputInstance.Height = currentlyEditing.getHeight() + 20; textInputInstance.Width = currentlyEditing.getWidth() + 20; textInputInstance.BorderThickness = new Thickness(0); textInputInstance.FontSize = font.height; textInputInstance.Margin = new Thickness(0); textInputInstance.Padding = new Thickness(0); textInputInstance.Clip = null; textInputInstance.AcceptsReturn = !currentlyEditing.isSingleLineTextArea(); textInputInstance.Focus(); are.Set(); }); are.WaitOne(); } d.invokeAndBlock(new WaitForEdit()); using (AutoResetEvent are = new AutoResetEvent(false)) { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { cl.Children.Remove(textInputInstance); textInputInstance = null; //cl.Focus(); }); } }