Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.Native.SearchBar"/> class.
        /// </summary>
        /// <param name="parent">Parent evas object.</param>
        public SearchBar(EvasObject parent) : base(parent)
        {
            _entry = new Entry(parent)
            {
                IsSingleLine = true,
            };
            _entry.SetInputPanelReturnKeyType(InputPanelReturnKeyType.Search);
            _entry.TextChanged += EntryTextChanged;
            _entry.Activated   += EntryActivated;
            _entry.Focused     += EntryFocused;
            _entry.Unfocused   += EntryUnfocused;
            _entry.Show();

            _cancelButton          = new Button(parent);
            _cancelButton.Style    = CancelButtonLayoutStyle;
            _cancelButton.Clicked += CancelButtonClicked;

            _underlineRectangle = new ERectangle(parent)
            {
                Color = IsEnabled ? s_underlineColor : s_underlineDimColor,
            };
            _underlineRectangle.Show();

            Children.Add(_entry);
            Children.Add(_cancelButton);
            Children.Add(_underlineRectangle);

            Show();

            this.LayoutUpdated += SearchBarLayoutUpdated;
        }
        void CreatePopup()
        {
            var rect = XForms.NativeParent.Geometry;

            var root = FindWindow(XForms.NativeParent);

            _editorPopup = new Background(root)
            {
                Geometry = rect
            };

            var layout = new ELayout(_editorPopup);
            layout.SetTheme("layout", "entry", "default");
            layout.Show();

            _editorPopup.SetPartContent("overlay", layout);

            _editor = new Xamarin.Forms.Platform.Tizen.Native.Entry(layout);
            _editor.IsSingleLine = true;
            _editor.Scrollable = true;
            _editor.SetInputPanelEnabled(false);
            _editor.AllowFocus(true);
            _editor.PrependMarkUpFilter(PopupEntryMaxLengthFilter);
            _editor.Show();

            _editor.SetInputPanelReturnKeyType(Element.ReturnType.ToInputPanelReturnKeyType());

            _editor.UpdateKeyboard(Element.Keyboard, Element.IsSpellCheckEnabled, Element.IsTextPredictionEnabled);

            _editorPopup.BackButtonPressed += (s, e) => HidePopup();

            _editor.Activated += (s, e) => HidePopup();

            IntPtr entryHandle = Interop.EFL.elm_entry_imf_context_get(_editor.RealHandle);

            _editorStateChanged = EditorStateChanged;
            Interop.EFL.ecore_imf_context_input_panel_event_callback_add(entryHandle, Interop.EFL.InputPanelEventType.State, _editorStateChanged, IntPtr.Zero);

            layout.SetPartContent("elm.swallow.content", _editor);
        }