denemo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Denemo-devel] CusorInSelection?


From: Nils Gey
Subject: [Denemo-devel] CusorInSelection?
Date: Sun, 28 Nov 2010 00:25:07 +0100

It is not possible with Scheme alone to test if the cursor is in the selection 
or not in 100% of the cases:

My method in Scheme is roughly this:

;;;Start
(define (selection::CursorInSelection?)   ; Tells if the cursor is in a 
selection or in an appending position to an ended selection
        (d-PushPosition)
        (d-MoveCursorRight) ; Just go a step right to get into position.
                (if  (d-PrevSelectedObject) ; 
                        (begin (d-PopPosition) #t) ; found note, we are in a 
selection
                        (begin (d-PopPosition) #f) ; found no note, no selection
                )
)
;;;;End

Basically I try to get into a position where I can be sure that either 
(d-NextSelectedObject) or (d-PrevSelectedObject) works. However this leads to 
obvious problems on StaffBeginning or StaffEnd. The method above has no problem 
with StaffBeginnings because it looks backwards. The other way around has no 
problem with Endings. 

But in case of a single selected note, alone in the whole staff, it will fail. 
Because you cannot go left or right anymore.
Well, technically you can move the cursor right and you will be in the 
appending position. Indeed this one is even available if you are at the end of 
a staff. But for d-PrevSelectedObject (and many other Denemo functions) 
Appending and the Object left to appending is the same thing. If you do 
Prev[Selected]Object you will not go to the object left/right but to the one 
next after. Which is not there for a single note. qed

Since so many scripts (I think the majority of scripts which do not use 
d-GetType as test) use that Appending and the Object left to appending are the 
same thing I think this calls for a C Solution.

greetings,
Nils



reply via email to

[Prev in Thread] Current Thread [Next in Thread]