void CreateDraggableFish() { var cache = ResourceCache; var graphics = Graphics; // Create a draggable Fish button draggableFish = new Button(); draggableFish.Texture = cache.GetTexture2D("Textures/UrhoDecal.dds"); // Set texture draggableFish.BlendMode = BlendMode.Add; draggableFish.SetSize(128, 128); draggableFish.SetPosition((graphics.Width - draggableFish.Width) / 2, 200); draggableFish.Name = "Fish"; uiRoot.AddChild(draggableFish); // Add a tooltip to Fish button ToolTip toolTip = new ToolTip(); draggableFish.AddChild(toolTip); toolTip.Position = new IntVector2(draggableFish.Width + 5, draggableFish.Width / 2); // slightly offset from close button BorderImage textHolder = new BorderImage(); toolTip.AddChild(textHolder); textHolder.SetStyle("ToolTipBorderImage", null); var toolTipText = new Text(); textHolder.AddChild(toolTipText); toolTipText.SetStyle("ToolTipText", null); toolTipText.Value = "Please drag me!"; // Subscribe draggableFish to Drag Events (in order to make it draggable) draggableFish.SubscribeToDragBegin(HandleDragBegin); draggableFish.SubscribeToDragMove(HandleDragMove); draggableFish.SubscribeToDragEnd(HandleDragEnd); }
private static ToolTip SetToolTip(this UIElement ele, string tip) { // Add a tooltip to Fish button ToolTip toolTip = new ToolTip(); toolTip.Position = new IntVector2(ele.Width + 5, ele.Width / 2); // slightly offset from close button BorderImage textHolder = new BorderImage(); toolTip.AddChild(textHolder); textHolder.SetStyle("ToolTipBorderImage", null); var toolTipText = GetText(tip, "ToolTipText"); textHolder.AddChild(toolTipText); ele.AddChild(toolTip); return(toolTip); }
void CreateDraggableFish() { var cache = ResourceCache; var graphics = Graphics; // Create a draggable Fish button draggableFish = new Button(); draggableFish.Texture = cache.GetTexture2D("Textures/UrhoDecal.dds"); // Set texture draggableFish.BlendMode = BlendMode.Add; draggableFish.SetSize(128, 128); draggableFish.SetPosition((graphics.Width - draggableFish.Width)/2, 200); draggableFish.Name = "Fish"; uiRoot.AddChild(draggableFish); // Add a tooltip to Fish button ToolTip toolTip = new ToolTip(); draggableFish.AddChild(toolTip); toolTip.Position = new IntVector2(draggableFish.Width + 5, draggableFish.Width/2); // slightly offset from close button BorderImage textHolder = new BorderImage(); toolTip.AddChild(textHolder); textHolder.SetStyle("ToolTipBorderImage", null); var toolTipText = new Text(); textHolder.AddChild(toolTipText); toolTipText.SetStyle("ToolTipText", null); toolTipText.Value = "Please drag me!"; // Subscribe draggableFish to Drag Events (in order to make it draggable) draggableFish.SubscribeToDragBegin(HandleDragBegin); draggableFish.SubscribeToDragMove(HandleDragMove); draggableFish.SubscribeToDragEnd(HandleDragEnd); }