Page 1 of 1

TextBox Selection- and CaretBrush

Posted: 26 Sep 2017, 15:52
by Gwynneth
I'm trying to change the Selection- and CaretBrush of a TextBox. Setting the properties works fine in WPF and Noesis 1.2. However, when using Unity 2017.1.1f1 and Noesis 2.1.0b4 it doesn't, any thoughts?

Re: TextBox Selection- and CaretBrush

Posted: 29 Sep 2017, 02:32
by sfernandez
I found a bug in the ShowSoftwareKeyboardCallback definition (NoesisGUI.cs) that made caret hidden by default.

The fix is just changing the return type of that callback to bool type: (Assets/NoesisGUI/Plugins/API/Core/NoesisGUI.cs line 152)
delegate bool ShowSoftwareKeyboardCallback(IntPtr focusedElement);
private static ShowSoftwareKeyboardCallback _showSoftwareKeyboard = ShowSoftwareKeyboard;
[MonoPInvokeCallback(typeof(ShowSoftwareKeyboardCallback))]
private static bool ShowSoftwareKeyboard(IntPtr focusedElement)
{
    try
    {
        if (_initialized)
        {
            UIElement element = Extend.GetProxy(focusedElement, false) as UIElement;
            return _softwareKeyboard.Show(element);
        }
    }
    catch (Exception e)
    {
        Noesis.Error.SetNativePendingError(e);
    }

    return false;
}
After that change, are you being able to correctly see the caret and change Selection and Caret Brushes?

Re: TextBox Selection- and CaretBrush

Posted: 29 Sep 2017, 10:19
by Gwynneth
I found a bug in the ShowSoftwareKeyboardCallback definition (NoesisGUI.cs) that made caret hidden by default.

The fix is just changing the return type of that callback to bool type: (Assets/NoesisGUI/Plugins/API/Core/NoesisGUI.cs line 152)
delegate bool ShowSoftwareKeyboardCallback(IntPtr focusedElement);
private static ShowSoftwareKeyboardCallback _showSoftwareKeyboard = ShowSoftwareKeyboard;
[MonoPInvokeCallback(typeof(ShowSoftwareKeyboardCallback))]
private static bool ShowSoftwareKeyboard(IntPtr focusedElement)
{
    try
    {
        if (_initialized)
        {
            UIElement element = Extend.GetProxy(focusedElement, false) as UIElement;
            return _softwareKeyboard.Show(element);
        }
    }
    catch (Exception e)
    {
        Noesis.Error.SetNativePendingError(e);
    }

    return false;
}
After that change, are you being able to correctly see the caret and change Selection and Caret Brushes?

Yes, it works now, thanks!