RE: [Fxruby-users] Newbie question about making own drawables
Status: Inactive
Brought to you by:
lyle
From: Will M. <wi...@co...> - 2003-11-24 23:26:33
|
On Sunday, November 23, 2003 6:10 PM, Fredrik Jagenheim wrote: > I want to make something that's pretty simple. I want to have > a couple of objects drawn on a canvas. These objects should > be event-aware, so I get notified if they're clicked, dragged > or otherwise manipulated. As it happens, I am using FXRuby, Fox and Ruby to prototype an app I have in mind and so far have implemented a small application that does a lot of what you ask. Right now its spread across a half dozen files so I won't include it here, but if there is (or could be) a site to post "in progress" code, I would be happy to share it. (I am hoping soon to create a website of my own for this project, but for now its on my "real soon now" list.) Actually, I would love a site where we could post some code and give and get feedback. I have no idea if what I am writing is good Ruby/Fox/FXRuby code or not. Any ideas or possibilities? May such a thing already exists? > But I can't even figure out which FX object to inherit from. > Neither 'FXDrawable' or 'FXImage' implements the 'connect' method. > > And since I can't even get to know when SEL_PAINT is requested, > I don't know how I can get to know if a key has been pressed > from SEL_KEYPRESSED. The aproach I took was to simply use an FXWindow and set up a couple of event handlers on mouse down, move and up. Each object (stored in a simple array of objects. Boy this language is fun!) handles its own drawing and has a method to determine if the mouse coordiates are inside it. So when I click on an object, the FXWindow iterates over each object until one says "That's me!" and then that one becomes the current object for all subsequent operations. Most of this is handled by a base "drawable object" class that handles most of this, and then each type of object is subclassed from it. For the last week or two I have been trying to implement a Delphi style "Object Inspector" to work with this, and it has been kicking my butt. I am trying to use the FoxTails/Observable extensions. I like the way it works when I can figure it out, but the documentation and examples are so scant that it is really hard to figure out, at least in my case. > I guess my lack of knowledge of how to program GUI is > the major culprit here, but could someone please point > me to some documents which could help me out? The stuff > I find on FXRuby seems to assume that I already know > Fox and the document on Fox assumes that I'm using > C++, although I'd suppose it's pretty easy to translate > into Ruby? You're right, the documentation is a bit thinner than I would like too, but you can work it out by studying the examples and using lots of "print" statements. I recomend launching your app from a command line so you can see the output as it happens. I also recomend the "code'a'little, test'a'little" approach. Start with something that works, make small changes, then test your changes, fixing then until they work. Repeat. Frequently. -- Will Merrell |