Simon
Simon

Reputation: 21

Creating a view with draggable text elements

I am trying to create a view for a kind of brainstorming application like, for example, OmniGraffle, with elements that contain textviews and can be dragged around. (Also, the should be connectable with arrows, but that is not (yet) the problem)

I did my homework and searched via google and read books about cocoa, but there seems to be no similar example around. Since I am also new to cocoa, I’m a bit helpless here.

The thing I am sure of is, that I need a custom view in which I can create my elements - what I tried until now to do that is:

Well, now that nothing works and the more I read, the more problems seem to occur, I am pretty confused and frustrated.
How could I realize such a program? Could someone please push me in the right direction?

Upvotes: 2

Views: 288

Answers (1)

Simon
Simon

Reputation: 23

I created a class for the draggable elements where I save position, size and text in instance variables. In my view, every new element instance is added to an array (for now, this works without a controller). The array is used to draw all the elements in a loop in drawRect:. For the text of the element I just use a NSTextFieldCell which is set to the saved text from every element in the same loop.

That way it is also possible to overlap the elements.

Upvotes: 1

Related Questions