Integrated Application Platform › Forums › General › Newb Window Canvas Question
- This topic has 7 replies, 2 voices, and was last updated 12 years, 7 months ago by
roundtuit.
-
AuthorPosts
-
April 9, 2011 at 1:09 pm #695
roundtuit
ParticipantI have created a window (see code below) that contains a Menu and a Canvas. After creating the window, I do some other things in Dialogs and now want to get back to my Canvas to add some items to it. I cannot find how to do that. Anyone help? Please?
Window(Controller
{
Title: "Stuff"
Commands:
(
(Cut, "Ctrl+X", "Cut the selected text to the clipboard")
(Copy, "Ctrl+C", "Copy the selected text to the clipboard")
(Paste, "Ctrl+V", "Insert the contents of the clipboard")
)
Menu:
(
("&AAAAA",
"&Add", "&Browse", "&Edit")
("&BBBBB",
"&Add", "&Browse", "&Edit", "&Delete")
("&CCCCC",
"&Add", "&Browse", "&Edit", "&Delete")
("&DDDDD",
"&Indiv Payment", "&Bulk Payment", "&Notice")
)
Controls:
(Vert
(Canvas)
)
})
//Do some stuff here in Dialogs
ob = .Vert.Canvas results in "Function does not support get" here
ob.AddItem(CanvasText("Test",50, 50, 150, 150, ))
April 9, 2011 at 1:33 pm #826amckinlay
KeymasterYou need to keep a reference to the Window.
w = Window(…
Then you can do:
w.Vert.Canvas.AddItem(…
Or if it’s just setup stuff, you can do it in a New method in the Controller.
I’m not sure how much Canvas has been used lately so let me know if there are any problems.
April 9, 2011 at 5:34 pm #827roundtuit
ParticipantOK, I turned my nifty little window builder into a function with a
return w
Just prior to the return, from withing the function I tried
w.Vert.Canvas.AddItem( which yielded “uninitialized member: #Vert”
So I tried the same thing external to the function and still got the same error.
April 9, 2011 at 5:54 pm #828amckinlay
KeymasterSorry, my mistake.
Here’s what I ran from the WorkSpace:
w = Window(#(Vert (Canvas)))
w.Vert.CanvasI missed that you’re using a Controller, so it becomes:
w = Window(Controller { Controls: (Vert (Static hello)) })
w.Ctrl.Vert.Canvas(the top level control in a window can be referenced as Ctrl)
You can always do Inspect(w) to see what you’re getting.
It is often better is to use FindControl
w.FindControl(‘Canvas’)
This will search through the control tree for a control with that name, so it won’t break when you change your layout.
If you have multiple controls of the same type you need to give them unique names:
(Vert (Field name: one) (Field name: two))
April 9, 2011 at 6:57 pm #829roundtuit
ParticipantPerfect! Works like a charm and even makes sense to this old brain. Thanks much!!!
April 11, 2011 at 3:32 pm #830roundtuit
ParticipantStill just a little lost… I run my function to create the window (w = MyFunc) and it returns the pointer to the window (window object) as w beautifully. There’s my Window, my Menu, My canvas. Everything is wonderful. now I get the pointer to my canvas (oc = w.FindControl(‘Canvas’)) and there it is, big and beautiful as life…My Canvas. Now, silly me, I want to put an image on my canvas so I try to create an image object with oi = Image(“MyFile.jpg”) so that I can add it (oc.AddItem) to my canvas. No joy in Mudville. Image(“MyFile.jpg”) just appears to return a string that says “Image (“MyFile.jpg”)” and not an object that I can manipulate or add to the canvas. I’m trying all this from the workspace, 1 line at a time so I can see what I’m getting. What did I do wrong THIS time?
Oh, and is there something simple I can specify in my Window creation function that will start the window maximized? Thanks so much and sorry to be such a bother.
April 11, 2011 at 4:41 pm #831amckinlay
KeymasterI think you need to add a CanvasImage. Image is a lower level built-in class for loading image files.
Canvas was written for DrawControl (SuneiDraw). You can look at the DrawControl code for usage.
Is there a particular reason you are using Canvas? You’re welcome to use it, but it’s not the normal user interface for Suneido. (We don’t use it in any of our applications.)
April 11, 2011 at 6:24 pm #832roundtuit
Participant@amckinlay wrote:
Is there a particular reason you are using Canvas? You’re welcome to use it, but it’s not the normal user interface for Suneido. (We don’t use it in any of our applications.)
Ahh… I see, I chose the chainsaw instead of the hammer to drive the nail, sorry about that and thanks for pointing out the hammer… MUCH better. Canvas looks like a cute control that I could use to do some interesting things, have some fun with and let the user possibly have some fun with as well. Maybe I’ll give them some pens and crayons and they can doodle and color while they wait on the phone, instead of using up the boss’ paper pads. I rarely do anything as mundane as “normal”, life is too short! 😉
-
AuthorPosts
- You must be logged in to reply to this topic.