Page 1 of 1

PredictFocus() throw error

Posted: 08 Apr 2016, 13:58
by lomoonmoonbird
Hi
When I want to Predict the next button with a button clicked ,an error occurred:
ApplicationException: Implement FrameworkElement::PredictFocus
Noesis.UIElement.PredictFocus (FocusNavigationDirection direction) (at Assets/Plugins/NoesisGUI/Scripts/Proxies/UIElement.cs:4236)
putaogame.usercontrols.MyControl1.lbutton4_KeyDown (System.Object sender, Noesis.KeyEventArgs e) (at Assets/putaogame/usercontrol/MyControl1.xaml.cs:87)
Noesis.UIElement.RaiseKeyDown (IntPtr cPtr, IntPtr sender, IntPtr e) (at Assets/Plugins/NoesisGUI/Scripts/Proxies/UIElement.cs:545)
UnityEngine.Debug:LogException(Exception)
Noesis.Debug:LogException(Exception) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisDebug.cs:24)
Noesis.Error:SetNativePendingError(Exception) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisError.cs:33)
Noesis.UIElement:RaiseKeyDown(IntPtr, IntPtr, IntPtr) (at Assets/Plugins/NoesisGUI/Scripts/Proxies/UIElement.cs:549)
System.Object:wrapper_native_00007FFA9D4AA790(Int32, Int32)
Noesis.UIRenderer:Noesis_KeyDown(Int32, Int32) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisUIRendererImports.cs:278)
Noesis.UIRenderer:ProcessEvent(Event, Boolean, Boolean) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisUIRenderer.cs:455)
NoesisGUIPanel:OnGUI() (at Assets/Plugins/NoesisGUI/Scripts/NoesisGUIPanel.cs:456)


NoesisException: Implement FrameworkElement::PredictFocus
Noesis.Error.Check () (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisError.cs:26)
Noesis.UIRenderer.Noesis_KeyDown (Int32 rendererId, Int32 key) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisUIRendererImports.cs:279)
Noesis.UIRenderer.ProcessEvent (UnityEngine.Event ev, Boolean enableKeyboard, Boolean enableMouse) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisUIRenderer.cs:455)
NoesisGUIPanel.OnGUI () (at Assets/Plugins/NoesisGUI/Scripts/NoesisGUIPanel.cs:456)
UserControl codes:

#if UNITY_5
#define NOESIS
#endif

#if NOESIS
  using Noesis;
  using UnityEngine;
  using System;
  using System.Collections;
  using System.Windows.Input;
using System.Runtime.InteropServices;
//add here namespaces required when compiling in Unity
#else
using System;
using System.Collections;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Controls.Primitives;
//add here namespaces required when compiling in Blend
#endif

namespace putaogame.usercontrols
{

    #if NOESIS
    [UserControlSource("Assets/putaogame/usercontrol/MyControl1.xaml")]
    #endif

    public partial class MyControl1 : UserControl
    {

        
        Noesis.Button lbutton1;
        Noesis.Button lbutton4;
        Noesis.UserControl mycontrol1;
        public MyControl1()
        {
            InitializeComponent();
            Debug.Log("this is user control");
        }

        public void  OnPostInit()
        {
            lbutton1 = (Noesis.Button)FindName("lbutton1");
            lbutton4 = (Noesis.Button)FindName("lbutton4");
            lbutton1.Focus();
            mycontrol1 = (Noesis.UserControl)FindName("MyControl1");
            mycontrol1.PreviewKeyDown += mycontrol_PreviewKeyDown;
            lbutton1.KeyDown += lbutton1_KeyDown;
            lbutton4.KeyDown += lbutton4_KeyDown;
        }


        private void mycontrol_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            Debug.Log("mycontrol_PreviewKeyDown--" + sender);

        }

        private void lbutton1_KeyDown(object sender, KeyEventArgs e)
        {
            e.Handled = false;
            var a = (Noesis.Button)e.Source;
           
            Debug.Log("sender1--" + sender );
            
        }
        DependencyObject predictionElement = null;
        private void lbutton4_KeyDown(object sender, KeyEventArgs e)
        {

            FocusNavigationDirection focusDirection = Noesis.FocusNavigationDirection.Down;
            //TraversalRequest request = new TraversalRequest(focusDirection);

            if (e.Key == Key.Down)
            {
                e.Handled = false;
                //Debug.Log(lbutton4.PredictFocus(FocusNavigationDirection.Down));
                predictionElement = lbutton4.PredictFocus(FocusNavigationDirection.Down);
                Debug.Log(predictionElement);

            }
            if(e.Key == Key.Right)
            {
                e.Handled = true;
            }
           
            
            Debug.Log("sender4--" + sender);

        }
    }
}
Is there any mistake i have made? Thanks~

Re: PredictFocus() throw error

Posted: 12 Apr 2016, 10:42
by sfernandez
Hi, there is no mistake in your side, but PredictFocus and MoveFocus are not implemented yet.
Could you please create a ticket in our bugtracker and we will add this feature to our planning.

Meanwhile, as I said in the other thread, you should move focus manually by capturing the KeyDown event.