Re: [dev] "Current Selection"
ashok _ wrote: > On Mon, Apr 7, 2008 at 9:55 AM, Mathias Bauer <[EMAIL PROTECTED]> wrote: >> >> > What I would really like to see ... but it doesnt seem to be possible >> > ... is for an XSelectionChangeListener to directly let me know if >> > text was selected or not without doing this textrange comparison >> > stuff (currently xselectionchange listener is invoked for >> > everything...even mere movement of the cursor). >> >> There is already a SelectionChangeListener support - but not at the >> model, but at the Controller(s). And IMHO this is the right place. >> Having a "getCurrentSelection" at the model is wrong IMHO and just made >> for the convenience of lazy developers. ;-) > > Yes, the XSelectionChangeListener at the controller level is what I > tried to use. > Unfortunately even moving the cursor in the document invokes a selectionChange > event (i.e. there is no text selected at all ) . > Is this is a bug , or is this the way it is ? The cursor also is a selection (a collapsed one). So if it is moved, the selection changes. That's the way it is. Ciao, Mathias -- Mathias Bauer (mba) - Project Lead OpenOffice.org Writer OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS Please don't reply to "[EMAIL PROTECTED]". I use it for the OOo lists and only rarely read other mails sent to it. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] "Current Selection"
On Mon, Apr 7, 2008 at 9:55 AM, Mathias Bauer <[EMAIL PROTECTED]> wrote: > > > What I would really like to see ... but it doesnt seem to be possible > > ... is for an XSelectionChangeListener to directly let me know if > > text was selected or not without doing this textrange comparison > > stuff (currently xselectionchange listener is invoked for > > everything...even mere movement of the cursor). > > There is already a SelectionChangeListener support - but not at the > model, but at the Controller(s). And IMHO this is the right place. > Having a "getCurrentSelection" at the model is wrong IMHO and just made > for the convenience of lazy developers. ;-) Yes, the XSelectionChangeListener at the controller level is what I tried to use. Unfortunately even moving the cursor in the document invokes a selectionChange event (i.e. there is no text selected at all ) . Is this is a bug , or is this the way it is ? ashok - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] "Current Selection"
ashok _ wrote: > What I would really like to see ... but it doesnt seem to be possible > ... is for an XSelectionChangeListener to directly let me know if > text was selected or not without doing this textrange comparison > stuff (currently xselectionchange listener is invoked for > everything...even mere movement of the cursor). There is already a SelectionChangeListener support - but not at the model, but at the Controller(s). And IMHO this is the right place. Having a "getCurrentSelection" at the model is wrong IMHO and just made for the convenience of lazy developers. ;-) Ciao, Mathias -- Mathias Bauer (mba) - Project Lead OpenOffice.org Writer OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS Please don't reply to "[EMAIL PROTECTED]". I use it for the OOo lists and only rarely read other mails sent to it. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] "Current Selection"
Hi Caolan, On Friday, 2008-04-04 09:44:08 +0100, Caolan McNamara wrote: > Hmm, I suspect that wouldn't give a correct answer to "is something > selected?" in the case of a spreadsheet In a spreadsheet, all operations apply to the current cell if no cell is selected, the selection returned in this case is the current cell, even if it isn't visibly marked. The difference is only in rendering or for user interaction such as starting drag&drop vs. extending the selection upon mouse point-and-drag. Is a differentiation needed elsewhere? Eike -- OOo/SO Calc core developer. Number formatter stricken i18n transpositionizer. SunSign 0x87F8D412 : 2F58 5236 DB02 F335 8304 7D6C 65C9 F9B5 87F8 D412 OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS Please don't send personal mail to the [EMAIL PROTECTED] account, which I use for mailing lists only and don't read from outside Sun. Use [EMAIL PROTECTED] Thanks. pgpnFiZm86CPP.pgp Description: PGP signature
Re: [dev] "Current Selection"
On Fri, Apr 4, 2008 at 11:44 AM, Caolan McNamara <[EMAIL PROTECTED]> wrote: > > > > No, you can ... > > > > - queryInterface the selection object for selection ranges > > (com.sun.star.text.TextRanges) > > - get the first selected range > > - get a cursor over the range > > - if the cursor is collapsed (cursor.isCollapsed() ) it means no text > > was selected, otherwise it means text was select > > Hmm, I suspect that wouldn't give a correct answer to "is something > selected?" in the case of a spreadsheet or drawing XModel instead of a > text document, nor in the case of a text document if e.g. only a graphic > is selected. > yes, my response was only in the context of a Writer document, dont know about spreadsheets. Checking if a graphic object is selected is quite easy (though a different use case). you just query the selection object if it supportsService("com.sun.star.text.TextGraphicObject") . ashok - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] "Current Selection"
On Fri, 2008-04-04 at 11:01 +0300, ashok _ wrote: > On Thu, Apr 3, 2008 at 9:54 PM, Caolan McNamara wrote: > > Am I right in that it is not possible to simply generically query any > > given xModel's getCurrentSelection() result to answer the question "is > > something selected". > > > > C. > > No, you can ... > > - queryInterface the selection object for selection ranges > (com.sun.star.text.TextRanges) > - get the first selected range > - get a cursor over the range > - if the cursor is collapsed (cursor.isCollapsed() ) it means no text > was selected, otherwise it means text was select Hmm, I suspect that wouldn't give a correct answer to "is something selected?" in the case of a spreadsheet or drawing XModel instead of a text document, nor in the case of a text document if e.g. only a graphic is selected. C. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] "Current Selection"
On Thu, Apr 3, 2008 at 9:54 PM, Caolan McNamara wrote: > Am I right in that it is not possible to simply generically query any > given xModel's getCurrentSelection() result to answer the question "is > something selected". > > C. No, you can ... - queryInterface the selection object for selection ranges (com.sun.star.text.TextRanges) - get the first selected range - get a cursor over the range - if the cursor is collapsed (cursor.isCollapsed() ) it means no text was selected, otherwise it means text was select What I would really like to see ... but it doesnt seem to be possible ... is for an XSelectionChangeListener to directly let me know if text was selected or not without doing this textrange comparison stuff (currently xselectionchange listener is invoked for everything...even mere movement of the cursor). I am trying to build functionality like a context sensitive toolbar that gets activated only when text is selectd (like the copy, paste toolbar in openoffice )... anyone know how to go about doing this ? ashok ashok - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[dev] "Current Selection"
Am I right in that it is not possible to simply generically query any given xModel's getCurrentSelection() result to answer the question "is something selected". C. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]