Have a canvas, in fact have eight, that may or may not have a background image. Would like when a canvas is clicked for the focus ring to show for the select canvas and not for the others. Also be able to keep track of which is the selected one. The canvas or setup in a class.
Help would be appreciated.
[quote=201333:@Jim Smith]Have a canvas, in fact have eight, that may or may not have a background image. Would like when a canvas is clicked for the focus ring to show for the select canvas and not for the others. Also be able to keep track of which is the selected one. The canvas or setup in a class.
Help would be appreciated.[/quote]
Jim what I do is subclass a “canvas” and then add a property called “isClicked” to this canvas subclass. I will then we can mark true or false for a canvas clicked in the canvas’ cellClick event. (You will have to determine how you want to mark/unmark your IsClicked properties.)
Having an array that is of the subclassed “canvas” type allows me to add all of my subclassed canvas’ to it in order to have an index to search through. For example if I see that array element  has isClicked property=true then I would change the focus ring on only that array element index.
Turn on the AcceptFocus property of Canvas and they’ll automatically focus from Tab and Shift-Tabbing. But to focus on click you’ll have to manually set it
Function MouseDown(X As Integer, Y As Integer) As Boolean
To know what’s currently selected call the windows Focus method
dim c As Canvas = self.Focus
But if there are controls other than your Canvas’ that can have focus that will crash.
Instead group your Canvas’ in a Control Set or as a Canvas subclass type. Then you can add a method that returns the Canvas or nil if something else is selected…
[code]//MyCanvas is the Control Set name or subclass name
Function getFocusedCanvas() As MyCanvas
if self.Focus IsA MyCanvas then
dim c As MyCanvas = getFocusedCanvas
if c <> nil then
MsgBox "focused on " + Str(c.Index) //Index relevant only for Control Sets
MsgBox “not focused on a MyCanvas”
Actually in the canvas subclass I would have a function (or calculated property):
Function HasFocus() As Boolean
return me.TrueWindow.Focus Is Me
Or better yet have an extension method in a module:
Function HasFocus(Extends theControl as RectControl) As Boolean
return theControl.TrueWindow.Focus Is theControl
That will work for any RectControl and no need to check for NIL.
It would be nice if that was in the framework actually.
Thanks all. They all look good. Will give them all a shot to see what fit my situation best.