[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kafka
Subject:    Re: Writing the selection code
From:       Jono Bacon <f9808590 () wlv ! ac ! uk>
Date:       2000-11-24 12:34:58
[Download RAW message or body]

On Thursday 23 November 2000 17:48, Thomas wrote:
> > Hello all,
> >
> > Over the pas few days I have been getting to grips with DOM, and I have
> > it straight, I can begin writing some of the selection methods.
> >
> > What we need are the following methods:
> >
> >  - To be able to click in the view and select an object
> >  - To be able to click inthe view and select where to write some text
> >  - To be able to highlight some text
> >  - To be able to highlight objects
>
> I understand that the DOM allows the editing of object via api calls,
> this means selecting, changing, adding.
>
> I would suggest a cursor object that can point to a dom object and the text
> in there.
> So the cursor could for example point to a specific <p> tag, character 10.
> The <p> tag should be referenced, meaning that moving the <p> tag to a <td>
> tag should not invalidate the cursor (I want it to remember where I was
> typing). The pointer should also save a position (in pixels) for the undo
> mechanism. For every undo a cursor would be saved so the cursor placement
> is remembered through undo/redos. But that is pretty advanced.
> Don't know if the QCursor can be used here..
>
> Highlighting text/objects means having 2 object references, a start
> object and an end object. Within these objects you could have a start/end
> position.
>
> For example:
>  <p>line1</p>
>   <hr>
>  <p>line2</p>
>
> selectionStart is firstP, character 3
> selectionEnd is lastP, character 5
>
> Remember that there are only 2 <P> objects in the above example, not 4 ;)
>
> Selecting on objects basis is the same, minus the character offsets. We
> just need a way to calculate which objects are between the first and last
> object. I think we need coordinates to calculate that..
>
> Basically you have 2 objects in your doc object for text
> selection and 2 objects for object selection. If you can use a <p>-type
> object for this; great!
>
> >  - Update the DOM tree with what the user does. If for example we want
> > to type text in it would find the node where the mouse is, take in
> > keyboard input for one letter, update the DOM, move the cursor
> > (keyboard) right one letter and repeat. For updating the DOM we can use
> > the KHTML DOM calls, and there is also a method which returns the DOM
> > node the user clicks on. This could be reimplemented.
>
> ehh, reimplemented?? Why not just use that?
> Read some of the earlier emails Schimmy wrote about this stuff.
>
> > If anyone has suggestions on a better way, or would like to get their
> > hands dirty, please speak up.
>
> Just  passing along some things, hope it helps.

OK...so to get a cursor in the HTML widget and add a letter to the DOM, the 
processing would go like this:

 - detect a QMouseEvent on the widget and connect it to a slot
 - in the slot, position the cursor where the click took place
 - also in the slot detect which object if any the mouse was over when the 
click occured
 - if there was an object go to that node in the dom tree, if not ?
 - wait for keyboard input and if it occurs add it tot he DOM tree

Is that right? The questions I have are:

 - how can a cursor object point to a DOM object? I assume you mean once the 
cursor has been set and the position in the DOM is set, update the posiition 
in the DOM tree each time the cursor moves.

 - if the position in the HTML widget is going to be set with setPos and 
using a QPoint, how can be line up the text with the cursor?

I am having a little trouble visualising your idea...although I am sure it 
will work well. It might be a good idea to write some code for the this to 
get it implemented if you have time.

	Jono


-- 
Jono Bacon - [vmlinuz] - jono@kde.org
KDE/Qt Developer - Kafka Maintainer
_______________________________________________
Kde-kafka mailing list
Kde-kafka@master.kde.org
http://master.kde.org/mailman/listinfo/kde-kafka

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic