User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: Creating a button dynamically (C++)

26 Aug 2014, 16:23

Unfortunately, we are yet unable to repro the problem. Could you please:

1. Paste us, the exact XAML you are using.
2. Try using that XAML in the minimal sample (the TUX one) included in the LeadWerks wrappers.

If these steps don't help with the problem we will probably need to debug your application to find the problem.
 
Michael_J
Topic Author
Posts: 20
Joined: 02 Apr 2014, 14:22

Re: Creating a button dynamically (C++)

26 Aug 2014, 16:56

Sure. Here's the XAML. It's commented so you have a better idea of what does what. The buttons I'm trying to add at run time get added to the "_pageNAV" canvas...
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="1000" Height="800" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Top" Background="#FF000000" TextElement.FontSize="14" TextElement.Foreground="Black">
   <Canvas.Resources>
      <ResourceDictionary>
         <ImageBrush x:Key="CHILDcntr_1" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="2,2,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_10" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="132,2,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_11" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="262,2,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="ICNplanBRRN" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="392,2,64,64" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="NAVcaret" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="458,2,32,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_12" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="2,36,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_13" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="132,36,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_14" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="262,36,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="ICNplanCRYO" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="392,68,64,64" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_15" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="2,70,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_16" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="132,70,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_17" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="262,70,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_18" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="2,104,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_19" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="132,104,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_2" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="262,104,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="ICNplanJOVI" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="392,134,64,64" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="ICNplanTERR" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="2,200,64,64" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_20" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="2,138,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_3" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="132,138,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_4" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="262,138,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="LookAtDot" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="2,266,64,64" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="ICNshipPLAYER" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="2,332,63,63" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="ICNshipSLCTD" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="2,397,63,63" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_5" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="2,462,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="ICNshipUNSLCTD" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="67,332,63,63" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_6" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="67,397,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_7" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="132,431,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_8" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="262,172,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="CHILDcntr_9" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="132,172,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="NAVmodeLEFT" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="132,465,128,32" ViewboxUnits="Absolute"/>
         <ImageBrush x:Key="NAVmodeRIGHT" AlignmentX="Left" AlignmentY="Top" ImageSource="Images/MFDicons.png" Stretch="Fill" Viewbox="68,206,128,32" ViewboxUnits="Absolute"/>
      </ResourceDictionary>
   </Canvas.Resources>
   
   <!-- Background gradient fill and lines-->
   <Rectangle Width="1000" Height="800" Canvas.Left="0" Canvas.Top="0" RadiusX="165" RadiusY="235" StrokeThickness="0">
      <Rectangle.Fill>
         <RadialGradientBrush GradientOrigin="0.5,0.5">
            <GradientStop Offset="0.0" Color="#FF000000"/>
            <GradientStop Offset="1.0" Color="#FF0B141C"/>
         </RadialGradientBrush>
      </Rectangle.Fill>
   </Rectangle>
   <Line Stroke="#FF22394F" StrokeThickness="1" X1="160" X2="160" Y1="0" Y2="800"/>
   <Line Stroke="#FF22394F" StrokeThickness="1" X1="840" X2="840" Y1="0" Y2="800"/>
   <Line x:Name="_lineDISTANCE" Stroke="#FF22394F" StrokeThickness="1" X1="500" X2="500" Y1="300" Y2="350"/>
   
   <!-- Selected celestial object info panel -->
   <StackPanel x:Name="_INFObox" Canvas.Left="400" Canvas.Top="540" HorizontalAlignment="Center" VerticalAlignment="Center">
      <TextBlock x:Name="_txtLINE0" FontSize="10" Foreground="#FF769ABD" Text="Name: "/>
      <TextBlock x:Name="_txtLINE1" FontSize="10" Foreground="#FF769ABD" Text="Class: "/>
      <TextBlock x:Name="_txtLINE2" FontSize="10" Foreground="#FF769ABD" Text="Inhabited: "/>
      <TextBlock x:Name="_txtLINE3" FontSize="10" Foreground="#FF769ABD" Text="Population: "/>
      <TextBlock x:Name="_txtLINE4" FontSize="10" Foreground="#FF769ABD" Text="Orbital Complex: "/>
      <TextBlock x:Name="_txtLINE5" FontSize="10" Foreground="#FF769ABD" Text="Tech Level: "/>
      <TextBlock x:Name="_txtLINE6" FontSize="10" Foreground="#FF769ABD" Text="Atmo Element A: "/>
      <TextBlock x:Name="_txtLINE7" FontSize="10" Foreground="#FF769ABD" Text="Atmo Element B: "/>
      <TextBlock x:Name="_txtLINE8" FontSize="10" Foreground="#FF769ABD" Text="Atmo Element C: "/>
      <TextBlock x:Name="_txtLINE9" FontSize="10" Foreground="#FF769ABD" Text="Crust Element A: "/>
      <TextBlock x:Name="_txtLINE10" FontSize="10" Foreground="#FF769ABD" Text="Crust Element B: "/>
      <TextBlock x:Name="_txtLINE11" FontSize="10" Foreground="#FF769ABD" Text="Crust Element C: "/>
      <TextBlock x:Name="_txtLINE12" FontSize="10" Foreground="#FF769ABD" Text="Rotational Period: "/>
      <TextBlock x:Name="_txtLINE13" FontSize="10" Foreground="#FF769ABD" Text="Orbit Period: "/>
      <TextBlock x:Name="_txtLINE14" FontSize="10" Foreground="#FF769ABD" Text="Orbit Inclination: "/>
      <TextBlock x:Name="_txtLINE15" FontSize="10" Foreground="#FF769ABD" Text="Orbit Apoapsis: "/>
      <TextBlock x:Name="_txtLINE16" FontSize="10" Foreground="#FF769ABD" Text="Orbit Periapsis: "/>
   </StackPanel>
   
   <!-- NAVIGATION page canvas -->
   <Canvas x:Name="_pageNAV" Width="1000" Height="800" Canvas.Left="0" Canvas.Top="0">
      <Ellipse Width="200" Height="200" Canvas.Left="400" Canvas.Top="300" HorizontalAlignment="Center" VerticalAlignment="Center" Stroke="#FF22394F" StrokeDashArray="8,8" StrokeThickness="1">
      </Ellipse>
      
      <!-- Left and Right action buttons -->
      <TextBlock x:Name="_MODEleftTEXT_0" Canvas.Right="855" Canvas.Top="224" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="13" Foreground="#FF769ABD" Text="ZOOM IN"/>
      <Button x:Name="_MODEleft_0" Width="133" Height="26" Canvas.Left="8" Canvas.Top="220" Margin="5,0" Background="#00000000" BorderThickness="0">
         <Rectangle Width="131" Height="24" Fill="{StaticResource NAVmodeLEFT}"/>
      </Button>
      <TextBlock x:Name="_MODEleftTEXT_1" Canvas.Right="855" Canvas.Top="304" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="13" Foreground="#FF769ABD" Text="ZOOM OUT"/>
      <Button x:Name="_MODEleft_1" Width="133" Height="26" Canvas.Left="8" Canvas.Top="300" Margin="5,0" Background="#00000000" BorderThickness="0">
         <Rectangle Width="131" Height="24" Fill="{StaticResource NAVmodeLEFT}"/>
      </Button>
      <TextBlock x:Name="_MODEleftTEXT_2" Canvas.Right="855" Canvas.Top="384" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="13" Foreground="#FF769ABD" Text="INTERCEPT"/>
      <Button x:Name="_MODEleft_2" Width="133" Height="26" Canvas.Left="8" Canvas.Top="380" Margin="5,0" Background="#00000000" BorderThickness="0">
         <Rectangle Width="131" Height="24" Fill="{StaticResource NAVmodeLEFT}"/>
      </Button>
      <TextBlock x:Name="_MODEleftTEXT_3" Canvas.Right="855" Canvas.Top="464" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="13" Foreground="#FF769ABD" Text="ORBIT SOLUTION"/>
      <Button x:Name="_MODEleft_3" Width="133" Height="26" Canvas.Left="8" Canvas.Top="460" Margin="5,0" Background="#00000000" BorderThickness="0">
         <Rectangle Width="131" Height="24" Fill="{StaticResource NAVmodeLEFT}"/>
      </Button>
      <TextBlock x:Name="_MODEleftTEXT_4" Canvas.Right="855" Canvas.Top="544" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="13" Foreground="#FF769ABD" Text="TRAJECTORY"/>
      <Button x:Name="_MODEleft_4" Width="133" Height="26" Canvas.Left="8" Canvas.Top="540" Margin="5,0" Background="#00000000" BorderThickness="0">
         <Rectangle Width="131" Height="24" Fill="{StaticResource NAVmodeLEFT}"/>
      </Button>
      <TextBlock x:Name="_MODErightTEXT_0" Canvas.Left="855" Canvas.Top="224" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="13" Foreground="#FF769ABD" Text="BASIC DATA"/>
      <Button x:Name="_MODEright_0" Width="133" Height="26" Canvas.Right="8" Canvas.Top="220" Margin="5,0" Background="#00000000" BorderThickness="0">
         <Rectangle Width="131" Height="24" Fill="{StaticResource NAVmodeRIGHT}"/>
      </Button>
      <TextBlock x:Name="_MODErightTEXT_1" Canvas.Left="855" Canvas.Top="304" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="13" Foreground="#FF769ABD" Text="GEOLOGIC"/>
      <Button x:Name="_MODEright_1" Width="133" Height="26" Canvas.Right="8" Canvas.Top="300" Margin="5,0" Background="#00000000" BorderThickness="0">
         <Rectangle Width="131" Height="24" Fill="{StaticResource NAVmodeRIGHT}"/>
      </Button>
      <TextBlock x:Name="_MODErightTEXT_2" Canvas.Left="855" Canvas.Top="384" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="13" Foreground="#FF769ABD" Text="ATMOSPHERIC"/>
      <Button x:Name="_MODEright_2" Width="133" Height="26" Canvas.Right="8" Canvas.Top="380" Margin="5,0" Background="#00000000" BorderThickness="0" Padding="0">
         <Rectangle Width="131" Height="24" Fill="{StaticResource NAVmodeRIGHT}"/>
      </Button>
      <TextBlock x:Name="_MODErightTEXT_3" Canvas.Left="855" Canvas.Top="464" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="13" Foreground="#FF769ABD" Text="ECONOMICS"/>
   <Button x:Name="_MODEright_3" Width="133" Height="26" Canvas.Right="8" Canvas.Top="460" Margin="5,0" Background="#00000000" BorderThickness="0">
      <Rectangle Width="131" Height="24" Fill="{StaticResource NAVmodeRIGHT}"/>
   </Button>
      <TextBlock x:Name="_MODErightTEXT_4" Canvas.Left="855" Canvas.Top="544" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="13" Foreground="#FF769ABD" Text="TOGGLE ALL"/>
      <Button x:Name="_MODEright_4" Width="133" Height="26" Canvas.Right="8" Canvas.Top="540" Margin="5,0" Background="#00000000" BorderThickness="0">
         <Rectangle Width="131" Height="24" Fill="{StaticResource NAVmodeRIGHT}"/>
      </Button>
   </Canvas> <!-- End NAV page canvas -->
   
   <!-- Upper mode selector buttons (NAV, DOCKING, TARGET, TACTICAL, ETC -->
   <Button x:Name="_PAGEnavBTN" Width="150" Height="30" Canvas.Left="170" Canvas.Top="15" HorizontalAlignment="Left" Margin="0" Background="#FF13202D" BorderBrush="#FF355A7E" BorderThickness="1">
      <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Foreground="#FF769ABD" Text="NAVIGATION"/>
   </Button>
   <Button x:Name="_PAGEdockBTN" Width="150" Height="30" Canvas.Left="338" Canvas.Top="15" HorizontalAlignment="Center" Margin="0" Background="#FF13202D" BorderBrush="#FF355A7E" BorderThickness="1">
      <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Foreground="#FF769ABD" Text="DOCKING"/>
   </Button>
   <Button x:Name="_PAGEtgtBTN" Width="150" Height="30" Canvas.Left="508" Canvas.Top="15" HorizontalAlignment="Center" Margin="0" Background="#FF13202D" BorderBrush="#FF355A7E" BorderThickness="1">
      <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Foreground="#FF769ABD" Text="TAGETING"/>
   </Button>
   <Button x:Name="_PAGEtacBTN" Width="150" Height="30" Canvas.Left="678" Canvas.Top="15" HorizontalAlignment="Center" Margin="0" Background="#FF13202D" BorderBrush="#FF355A7E" BorderThickness="1">
      <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Foreground="#FF769ABD" Text="TACTICAL"/>
   </Button>
   
   <!-- System state text -->
   <TextBlock x:Name="_NOTAVAILtxt" Canvas.Right="280" Canvas.Top="370" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="40" Foreground="#FF769ABD" Text="** MODE UNAVAILABLE **"/>
   <TextBlock x:Name="_INITIALtxt" Canvas.Right="280" Canvas.Top="370" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="40" Foreground="#FF769ABD" Text="**  MODE INITIALIZING  **"/>
   
   <!-- Caret/Mouse Pointer Representation -->
   <Border x:Name="_CURSOR" Width="15" Height="15" Canvas.Left="0" Canvas.Top="0" Margin="5,0" BorderBrush="Black" BorderThickness="0">
      <Rectangle Width="15" Height="15" Fill="{StaticResource NAVcaret}"/>
      <Border.RenderTransform>
         <TranslateTransform X="0" Y="0"/>
      </Border.RenderTransform>
   </Border>
   
</Canvas> <!-- End Main Canvas -->
 
User avatar
sfernandez
Site Admin
Posts: 2991
Joined: 22 Dec 2011, 19:20

Re: Creating a button dynamically (C++)

26 Aug 2014, 17:43

I think I know what the problem is... as suspected there are UI elements over the canvas named _pageNAV.

You have a Border named _CURSOR that I suppose is moved together with the mouse, that is placed over all the other elements. If you don't want that this element captures mouse events, you can set the IsHitTestVisible property to false:
<Border x:Name="_CURSOR" Width="15" Height="15" Canvas.Left="0" Canvas.Top="0" Margin="5,0" BorderBrush="Black" BorderThickness="0" IsHitTestVisible="False"> ...
Let me know if this fixes your problems.
 
Michael_J
Topic Author
Posts: 20
Joined: 02 Apr 2014, 14:22

Re: Creating a button dynamically (C++)

26 Aug 2014, 18:08

Sorry, but that did not fix the problem. I even tried adding it to both the Border (as you suggested) and the child rectangle that displays the cursor image. :( I would think, too, that if this were the problem it would also affect the "Upper mode selector buttons", which are also created before the cursor.

Again, buttons created on the main canvas (both in XAML and dynamically) do work fine. It's only the ones on the sub-canvas that do not. At this point, as a work-around until this is sorted out, I'll probably put each page in a separate XAML, and just update/display the appropriate one as needed...

Thank you for the continued assistance though...
 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: Creating a button dynamically (C++)

27 Aug 2014, 21:37

Hi Michael,

Could you please disable the code that updates the _CURSOR, or even better, eliminate the _CURSOR element from the XAML and verify is the problem is still there.

Thanks!
 
Michael_J
Topic Author
Posts: 20
Joined: 02 Apr 2014, 14:22

Re: Creating a button dynamically (C++)

28 Aug 2014, 03:57

Done (tried both)--no help. The problem is still there. Sorry...
 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: Creating a button dynamically (C++)

28 Aug 2014, 18:41

Next step. I need you to send me a zip with a XAML and all dependencies needed (images, fonts) that works as expected in XamlPlayer but doesn't work in your engine. This XAML must fail without having to do anything in code.

Let's see if with that we can advance...
 
Michael_J
Topic Author
Posts: 20
Joined: 02 Apr 2014, 14:22

Re: Creating a button dynamically (C++)

28 Aug 2014, 19:38

Check your email. I sent a .rar with both the XAML and the 1 required atlas .png
 
User avatar
sfernandez
Site Admin
Posts: 2991
Joined: 22 Dec 2011, 19:20

Re: Creating a button dynamically (C++)

29 Aug 2014, 19:56

Hi,

Could you verify that buttons placed inside the _pageNAV don't react to the Click event?
Attach an event handler to the Click event and see if the handler is called (although the visual representation of the button doesn't changes).

We found a problem with the default style that doesn't changes visual representation of the Button on mouse over/press if the Button has a Background/BorderBrush set (overriding style default brush).
 
Michael_J
Topic Author
Posts: 20
Joined: 02 Apr 2014, 14:22

Re: Creating a button dynamically (C++)

29 Aug 2014, 20:46

Verified -- any button placed in _pageNAV (either in the XAML or at runtime) has no reaction to the click event. The click event is never called...

Who is online

Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 11 guests