GUIBitmap focus
by Rich Hudson · in Torque X 2D · 11/03/2007 (4:23 pm) · 2 replies
Having trouble getting focus on a bitmap. Code:
//Style
//Create Inventory Bitmap Style
GUIBitmapStyle bitmapStyleInv = new GUIBitmapStyle();
bitmapStyleInv.SizeToBitmap = false;
bitmapStyleInv.PreserveAspectRatio = true;
bitmapStyleInv.Focusable = true;
//Bitmap
//Inventory Screen
inventoryScreen = new GUIBitmap();
inventoryScreen.Folder = gui;
inventoryScreen.Name = "inventoryScreen";
inventoryScreen.Style = bitmapStyleInv;
inventoryScreen.Bitmap = @"data\images\inventory";
inventoryScreen.Position = new Vector2(10.0f, 50.0f);
inventoryScreen.Size = new SizeF(256.0f, 418.0f);//366.0f, 597.0f);
inventoryScreen.Visible = true;
inventoryScreen.OnGUIGainFocus += _guiGainFocus;
//Event
//Note this is just a test..
private void _guiGainFocus(GUIControl ctrl)
{
messageText.Text = ctrl.Name;
messageText.Visible = true;
}
What am I missing?
//Style
//Create Inventory Bitmap Style
GUIBitmapStyle bitmapStyleInv = new GUIBitmapStyle();
bitmapStyleInv.SizeToBitmap = false;
bitmapStyleInv.PreserveAspectRatio = true;
bitmapStyleInv.Focusable = true;
//Bitmap
//Inventory Screen
inventoryScreen = new GUIBitmap();
inventoryScreen.Folder = gui;
inventoryScreen.Name = "inventoryScreen";
inventoryScreen.Style = bitmapStyleInv;
inventoryScreen.Bitmap = @"data\images\inventory";
inventoryScreen.Position = new Vector2(10.0f, 50.0f);
inventoryScreen.Size = new SizeF(256.0f, 418.0f);//366.0f, 597.0f);
inventoryScreen.Visible = true;
inventoryScreen.OnGUIGainFocus += _guiGainFocus;
//Event
//Note this is just a test..
private void _guiGainFocus(GUIControl ctrl)
{
messageText.Text = ctrl.Name;
messageText.Visible = true;
}
What am I missing?
Torque Owner rwillis
You can also use these below which causes the engine to automatically give focus to the next or previous control object, with "next" being downward(+Y) or to the right and "previous" being upward (-Y) or to the left depending on teh SearchPolicy:
or
You can also use GUICanvas.Instance.SetFocusControl(GUIControl ctrl) so all you'd do is:
GUICanvas.Instance.SetFocusControl("inventoryScreen");