Quantcast

use of getScript

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

use of getScript

derek riemer

Why is getScript used in the mathPlayer class? I figured binding gestures would work fine for my latex-access overlay class which is done in edit fields and allows you to move through matrices, but only the tab and shift tab scripts do. The arrows just don't do anything.

The class is below.
class MatrixBrowserNVDAObject(MathInteractionNVDAObject):
    """
    An NVDA object allowing for navigation through matrices.
    Pressing tab and shift+tab focus the next and previous matrix.
    Pressing arrow keys allow for movement around this matrix.
    """
   
    def __init__(self, provider=None, latex=None, cur=None, matrixNumber=0):
        super(MatrixBrowserNVDAObject, self).__init__(provider=provider)
        self.matrix=latex_access.matrix_processor.matrix()
        self.matrix.tex_init(latex )
        # The msg variable is here to say how many rows and columns have been initialised.
        msg = _("Initialised")
        msg = msg + str (self.matrix.rows)
        msg = msg + _(" by ")
        msg = msg + str(self.matrix.columns)
        msg = msg +_( " matrix")
        ui.message (msg)
        self.matrixNumber = matrixNumber
        self.row=1
        self.column=1
        self.previous = cur
        self.next = None

    def create(self, latex):
        if self.next is not None:
            raise ValueError("You must only create a matrix at the end of the set")
        self.next = MatrixBrowserNVDAObject(latex = latex, cur=self, matrixNumber = self.matrixNumber+1)
        return self.next

    def speakMatrix(self):
        matrix=[
            "Matrix %d" % self.matrixNumber,
            "Begin matrix",
            speech.BreakCommand(400)]
        for i in range(1, self.matrix.rows+1) :
            matrix+=self.speakRow(i)
            matrix.append(speech.BreakCommand(300))
        speech.speak(matrix+["end matrix"])

    def speakRow(self, row):
        temp = ["row "+str(row)+": ",
            speech.BreakCommand(300)]
        temp.append(speech.PitchCommand(1.25))
        for i in xrange(1,self.matrix.columns+1):
            temp+=[str(self.matrix.get_cell(row,i)), speech.BreakCommand(180)]
        temp.append(speech.PitchCommand(0.25))
        return temp

    def event_gainFocus(self):
        self.speakMatrix()

    def script_nextRow(self, gesture):
        """ Increases the row count by 1 if possible, speaking the new row, or speaks that the edge was reached. """
        if self.row == self.matrix.rows:
            ui.message("End of column.")
        else:
            self.row+=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_previousRow(self, gesture):
        """Decreases the row count by 1 if possible, speaking the new row, or speaks that the edge was reached. """
        if self.row == 1:
            ui.message("beginning of column.")
        else:
            self.row-=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_nextColumn(self, gesture):
        """ Increases the column count by 1 if possible, speaking the new column, or speaks that the edge was reached. """
        if self.column == self.matrix.columns:
            ui.message("End of row.")
        else:
            self.column+=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_previousColumn(self, gesture):
        """ Increases the column count by 1 if possible, speaking the new column, or speaks that the edge was reached. """
        import tones;tones.beep(500,55);print "testing"
        if self.column == 1:
            ui.message("Beginning of row.")
        else:
            self.column-=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_deleteMatrix(self, gesture):
        if self.next is None and self.previous is None:
            #last matrix in browser. Clean up.
            self.parent.curMatrix = self.parent.firstMatrix = self.parent.lastMatrix = None
        elif self.next is None:
            self.previous.next = None
            self.parent.curMatrix = self.parent.firstMatrix
            self.parent.lastMatrix = self.previous
        elif self.previous is None:
            self.next.previous = None
            self.parent.firstMatrix = self.parent.curMatrix = self.next
        else:
            self.previous.next = self.next
            self.next.previous = self.previous
            self.parent.curMatrix = self.next
        #Scilently renumber all matrices
        num=self.matrixNumber
        matrix = self.next
        while matrix:
            matrix.matrixNumber = num
            num+=1
            matrix = matrix.next
        self.parent.curMatrix.setFocus()
        del self

    def isOnlyMatrix(self):
        return not (self.next or  self.previous)

    def script_nextMatrix(self, gesture):
        if self.isOnlyMatrix():
            ui.message("There is only one matrix currently loaded.")
            return
        ui.message("Switching to next matrix")
        self.parent.curMatrix = (self.next if self.next else self.parent.firstMatrix)
        self.parent.curMatrix.setFocus()
    script_nextMatrix.__doc__ = "Goes to the next matrix in the browser if possible."

    def script_previousMatrix(self, gesture):
        if self.isOnlyMatrix():
            ui.message("There is only one matrix currently loaded.")
            return
        ui.message("Switching to previous matrix")
        self.parent.curMatrix = (self.previous if self.previous else self.parent.lastMatrix)
        self.parent.curMatrix.setFocus()
    script_previousMatrix.__doc__ = "Goes to the previous matrix in the browser if possible."

    __gestures = {
        "kb:upArrow" : "previousRow",
        "kb:downArrow" : "nextRow",
        "kb:leftArrow" : "previousColumn",
        "kb:rightArrow" : "nextColumn",
        "kb:tab" : "nextMatrix",
        "kb:shift+tab" : "previousMatrix",
        "kb:delete" : "deleteMatrix",
    }
--

Derek Riemer

  • Department of computer science, third year undergraduate student.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Member of Bridge Cu
  • Avid skiier.

Websites:
Honors portfolio
Awesome little hand built weather app!

[hidden email]
Phone: (303) 906-2194


------------------------------------------------------------------------------

_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: use of getScript

James Teh
What you're doing should work. Maybe the arrow keys are being overridden by an unintentional overlay class or something? Or a TreeInterceptor? Does input help logging report that the arrows are bound to something when you press them?

I used getScript for MathPlayer because I wanted to pass pretty much all keystrokes to MathPlayer without having to manually bind every one of them, especially since MathPlayer is basically just a black box to us; we can't access its key map or anything like that.


On Tue, Nov 22, 2016 at 9:06 AM, derek riemer <[hidden email]> wrote:

Why is getScript used in the mathPlayer class? I figured binding gestures would work fine for my latex-access overlay class which is done in edit fields and allows you to move through matrices, but only the tab and shift tab scripts do. The arrows just don't do anything.

The class is below.
class MatrixBrowserNVDAObject(MathInteractionNVDAObject):
    """
    An NVDA object allowing for navigation through matrices.
    Pressing tab and shift+tab focus the next and previous matrix.
    Pressing arrow keys allow for movement around this matrix.
    """
   
    def __init__(self, provider=None, latex=None, cur=None, matrixNumber=0):
        super(MatrixBrowserNVDAObject, self).__init__(provider=provider)
        self.matrix=latex_access.matrix_processor.matrix()
        self.matrix.tex_init(latex )
        # The msg variable is here to say how many rows and columns have been initialised.
        msg = _("Initialised")
        msg = msg + str (self.matrix.rows)
        msg = msg + _(" by ")
        msg = msg + str(self.matrix.columns)
        msg = msg +_( " matrix")
        ui.message (msg)
        self.matrixNumber = matrixNumber
        self.row=1
        self.column=1
        self.previous = cur
        self.next = None

    def create(self, latex):
        if self.next is not None:
            raise ValueError("You must only create a matrix at the end of the set")
        self.next = MatrixBrowserNVDAObject(latex = latex, cur=self, matrixNumber = self.matrixNumber+1)
        return self.next

    def speakMatrix(self):
        matrix=[
            "Matrix %d" % self.matrixNumber,
            "Begin matrix",
            speech.BreakCommand(400)]
        for i in range(1, self.matrix.rows+1) :
            matrix+=self.speakRow(i)
            matrix.append(speech.BreakCommand(300))
        speech.speak(matrix+["end matrix"])

    def speakRow(self, row):
        temp = ["row "+str(row)+": ",
            speech.BreakCommand(300)]
        temp.append(speech.PitchCommand(1.25))
        for i in xrange(1,self.matrix.columns+1):
            temp+=[str(self.matrix.get_cell(row,i)), speech.BreakCommand(180)]
        temp.append(speech.PitchCommand(0.25))
        return temp

    def event_gainFocus(self):
        self.speakMatrix()

    def script_nextRow(self, gesture):
        """ Increases the row count by 1 if possible, speaking the new row, or speaks that the edge was reached. """
        if self.row == self.matrix.rows:
            ui.message("End of column.")
        else:
            self.row+=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_previousRow(self, gesture):
        """Decreases the row count by 1 if possible, speaking the new row, or speaks that the edge was reached. """
        if self.row == 1:
            ui.message("beginning of column.")
        else:
            self.row-=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_nextColumn(self, gesture):
        """ Increases the column count by 1 if possible, speaking the new column, or speaks that the edge was reached. """
        if self.column == self.matrix.columns:
            ui.message("End of row.")
        else:
            self.column+=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_previousColumn(self, gesture):
        """ Increases the column count by 1 if possible, speaking the new column, or speaks that the edge was reached. """
        import tones;tones.beep(500,55);print "testing"
        if self.column == 1:
            ui.message("Beginning of row.")
        else:
            self.column-=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_deleteMatrix(self, gesture):
        if self.next is None and self.previous is None:
            #last matrix in browser. Clean up.
            self.parent.curMatrix = self.parent.firstMatrix = self.parent.lastMatrix = None
        elif self.next is None:
            self.previous.next = None
            self.parent.curMatrix = self.parent.firstMatrix
            self.parent.lastMatrix = self.previous
        elif self.previous is None:
            self.next.previous = None
            self.parent.firstMatrix = self.parent.curMatrix = self.next
        else:
            self.previous.next = self.next
            self.next.previous = self.previous
            self.parent.curMatrix = self.next
        #Scilently renumber all matrices
        num=self.matrixNumber
        matrix = self.next
        while matrix:
            matrix.matrixNumber = num
            num+=1
            matrix = matrix.next
        self.parent.curMatrix.setFocus()
        del self

    def isOnlyMatrix(self):
        return not (self.next or  self.previous)

    def script_nextMatrix(self, gesture):
        if self.isOnlyMatrix():
            ui.message("There is only one matrix currently loaded.")
            return
        ui.message("Switching to next matrix")
        self.parent.curMatrix = (self.next if self.next else self.parent.firstMatrix)
        self.parent.curMatrix.setFocus()
    script_nextMatrix.__doc__ = "Goes to the next matrix in the browser if possible."

    def script_previousMatrix(self, gesture):
        if self.isOnlyMatrix():
            ui.message("There is only one matrix currently loaded.")
            return
        ui.message("Switching to previous matrix")
        self.parent.curMatrix = (self.previous if self.previous else self.parent.lastMatrix)
        self.parent.curMatrix.setFocus()
    script_previousMatrix.__doc__ = "Goes to the previous matrix in the browser if possible."

    __gestures = {
        "kb:upArrow" : "previousRow",
        "kb:downArrow" : "nextRow",
        "kb:leftArrow" : "previousColumn",
        "kb:rightArrow" : "nextColumn",
        "kb:tab" : "nextMatrix",
        "kb:shift+tab" : "previousMatrix",
        "kb:delete" : "deleteMatrix",
    }
--

Derek Riemer

  • Department of computer science, third year undergraduate student.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Member of Bridge Cu
  • Avid skiier.

Websites:
Honors portfolio
Awesome little hand built weather app!

[hidden email]
Phone: <a href="tel:%28303%29%20906-2194" value="+13039062194" target="_blank">(303) 906-2194


------------------------------------------------------------------------------

_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel



------------------------------------------------------------------------------

_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: use of getScript

derek riemer

Input help: gesture kb(laptop):downArrow, bound to script reportLineOverflow on appModules.notepad++.editWindow.EditWindow

but I'm no longer focused on that edit field.


On 11/21/2016 4:51 PM, James Teh wrote:
What you're doing should work. Maybe the arrow keys are being overridden by an unintentional overlay class or something? Or a TreeInterceptor? Does input help logging report that the arrows are bound to something when you press them?

I used getScript for MathPlayer because I wanted to pass pretty much all keystrokes to MathPlayer without having to manually bind every one of them, especially since MathPlayer is basically just a black box to us; we can't access its key map or anything like that.


On Tue, Nov 22, 2016 at 9:06 AM, derek riemer <[hidden email]> wrote:

Why is getScript used in the mathPlayer class? I figured binding gestures would work fine for my latex-access overlay class which is done in edit fields and allows you to move through matrices, but only the tab and shift tab scripts do. The arrows just don't do anything.

The class is below.
class MatrixBrowserNVDAObject(MathInteractionNVDAObject):
    """
    An NVDA object allowing for navigation through matrices.
    Pressing tab and shift+tab focus the next and previous matrix.
    Pressing arrow keys allow for movement around this matrix.
    """
   
    def __init__(self, provider=None, latex=None, cur=None, matrixNumber=0):
        super(MatrixBrowserNVDAObject, self).__init__(provider=provider)
        self.matrix=latex_access.matrix_processor.matrix()
        self.matrix.tex_init(latex )
        # The msg variable is here to say how many rows and columns have been initialised.
        msg = _("Initialised")
        msg = msg + str (self.matrix.rows)
        msg = msg + _(" by ")
        msg = msg + str(self.matrix.columns)
        msg = msg +_( " matrix")
        ui.message (msg)
        self.matrixNumber = matrixNumber
        self.row=1
        self.column=1
        self.previous = cur
        self.next = None

    def create(self, latex):
        if self.next is not None:
            raise ValueError("You must only create a matrix at the end of the set")
        self.next = MatrixBrowserNVDAObject(latex = latex, cur=self, matrixNumber = self.matrixNumber+1)
        return self.next

    def speakMatrix(self):
        matrix=[
            "Matrix %d" % self.matrixNumber,
            "Begin matrix",
            speech.BreakCommand(400)]
        for i in range(1, self.matrix.rows+1) :
            matrix+=self.speakRow(i)
            matrix.append(speech.BreakCommand(300))
        speech.speak(matrix+["end matrix"])

    def speakRow(self, row):
        temp = ["row "+str(row)+": ",
            speech.BreakCommand(300)]
        temp.append(speech.PitchCommand(1.25))
        for i in xrange(1,self.matrix.columns+1):
            temp+=[str(self.matrix.get_cell(row,i)), speech.BreakCommand(180)]
        temp.append(speech.PitchCommand(0.25))
        return temp

    def event_gainFocus(self):
        self.speakMatrix()

    def script_nextRow(self, gesture):
        """ Increases the row count by 1 if possible, speaking the new row, or speaks that the edge was reached. """
        if self.row == self.matrix.rows:
            ui.message("End of column.")
        else:
            self.row+=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_previousRow(self, gesture):
        """Decreases the row count by 1 if possible, speaking the new row, or speaks that the edge was reached. """
        if self.row == 1:
            ui.message("beginning of column.")
        else:
            self.row-=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_nextColumn(self, gesture):
        """ Increases the column count by 1 if possible, speaking the new column, or speaks that the edge was reached. """
        if self.column == self.matrix.columns:
            ui.message("End of row.")
        else:
            self.column+=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_previousColumn(self, gesture):
        """ Increases the column count by 1 if possible, speaking the new column, or speaks that the edge was reached. """
        import tones;tones.beep(500,55);print "testing"
        if self.column == 1:
            ui.message("Beginning of row.")
        else:
            self.column-=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_deleteMatrix(self, gesture):
        if self.next is None and self.previous is None:
            #last matrix in browser. Clean up.
            self.parent.curMatrix = self.parent.firstMatrix = self.parent.lastMatrix = None
        elif self.next is None:
            self.previous.next = None
            self.parent.curMatrix = self.parent.firstMatrix
            self.parent.lastMatrix = self.previous
        elif self.previous is None:
            self.next.previous = None
            self.parent.firstMatrix = self.parent.curMatrix = self.next
        else:
            self.previous.next = self.next
            self.next.previous = self.previous
            self.parent.curMatrix = self.next
        #Scilently renumber all matrices
        num=self.matrixNumber
        matrix = self.next
        while matrix:
            matrix.matrixNumber = num
            num+=1
            matrix = matrix.next
        self.parent.curMatrix.setFocus()
        del self

    def isOnlyMatrix(self):
        return not (self.next or  self.previous)

    def script_nextMatrix(self, gesture):
        if self.isOnlyMatrix():
            ui.message("There is only one matrix currently loaded.")
            return
        ui.message("Switching to next matrix")
        self.parent.curMatrix = (self.next if self.next else self.parent.firstMatrix)
        self.parent.curMatrix.setFocus()
    script_nextMatrix.__doc__ = "Goes to the next matrix in the browser if possible."

    def script_previousMatrix(self, gesture):
        if self.isOnlyMatrix():
            ui.message("There is only one matrix currently loaded.")
            return
        ui.message("Switching to previous matrix")
        self.parent.curMatrix = (self.previous if self.previous else self.parent.lastMatrix)
        self.parent.curMatrix.setFocus()
    script_previousMatrix.__doc__ = "Goes to the previous matrix in the browser if possible."

    __gestures = {
        "kb:upArrow" : "previousRow",
        "kb:downArrow" : "nextRow",
        "kb:leftArrow" : "previousColumn",
        "kb:rightArrow" : "nextColumn",
        "kb:tab" : "nextMatrix",
        "kb:shift+tab" : "previousMatrix",
        "kb:delete" : "deleteMatrix",
    }
--

Derek Riemer

  • Department of computer science, third year undergraduate student.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Member of Bridge Cu
  • Avid skiier.

Websites:
Honors portfolio
Awesome little hand built weather app!

[hidden email]
Phone: <a moz-do-not-send="true" href="tel:%28303%29%20906-2194" value="+13039062194" target="_blank">(303) 906-2194


------------------------------------------------------------------------------

_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel




------------------------------------------------------------------------------


_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel

--

Derek Riemer

  • Department of computer science, third year undergraduate student.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Member of Bridge Cu
  • Avid skiier.

Websites:
Honors portfolio
Awesome little hand built weather app!

[hidden email]
Phone: (303) 906-2194


------------------------------------------------------------------------------

_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: use of getScript

derek riemer
In reply to this post by James Teh

yeah, it's also saying its bound to seditable text, so something is keeping it from receiving arrow keys.


On 11/21/2016 4:51 PM, James Teh wrote:
What you're doing should work. Maybe the arrow keys are being overridden by an unintentional overlay class or something? Or a TreeInterceptor? Does input help logging report that the arrows are bound to something when you press them?

I used getScript for MathPlayer because I wanted to pass pretty much all keystrokes to MathPlayer without having to manually bind every one of them, especially since MathPlayer is basically just a black box to us; we can't access its key map or anything like that.


On Tue, Nov 22, 2016 at 9:06 AM, derek riemer <[hidden email]> wrote:

Why is getScript used in the mathPlayer class? I figured binding gestures would work fine for my latex-access overlay class which is done in edit fields and allows you to move through matrices, but only the tab and shift tab scripts do. The arrows just don't do anything.

The class is below.
class MatrixBrowserNVDAObject(MathInteractionNVDAObject):
    """
    An NVDA object allowing for navigation through matrices.
    Pressing tab and shift+tab focus the next and previous matrix.
    Pressing arrow keys allow for movement around this matrix.
    """
   
    def __init__(self, provider=None, latex=None, cur=None, matrixNumber=0):
        super(MatrixBrowserNVDAObject, self).__init__(provider=provider)
        self.matrix=latex_access.matrix_processor.matrix()
        self.matrix.tex_init(latex )
        # The msg variable is here to say how many rows and columns have been initialised.
        msg = _("Initialised")
        msg = msg + str (self.matrix.rows)
        msg = msg + _(" by ")
        msg = msg + str(self.matrix.columns)
        msg = msg +_( " matrix")
        ui.message (msg)
        self.matrixNumber = matrixNumber
        self.row=1
        self.column=1
        self.previous = cur
        self.next = None

    def create(self, latex):
        if self.next is not None:
            raise ValueError("You must only create a matrix at the end of the set")
        self.next = MatrixBrowserNVDAObject(latex = latex, cur=self, matrixNumber = self.matrixNumber+1)
        return self.next

    def speakMatrix(self):
        matrix=[
            "Matrix %d" % self.matrixNumber,
            "Begin matrix",
            speech.BreakCommand(400)]
        for i in range(1, self.matrix.rows+1) :
            matrix+=self.speakRow(i)
            matrix.append(speech.BreakCommand(300))
        speech.speak(matrix+["end matrix"])

    def speakRow(self, row):
        temp = ["row "+str(row)+": ",
            speech.BreakCommand(300)]
        temp.append(speech.PitchCommand(1.25))
        for i in xrange(1,self.matrix.columns+1):
            temp+=[str(self.matrix.get_cell(row,i)), speech.BreakCommand(180)]
        temp.append(speech.PitchCommand(0.25))
        return temp

    def event_gainFocus(self):
        self.speakMatrix()

    def script_nextRow(self, gesture):
        """ Increases the row count by 1 if possible, speaking the new row, or speaks that the edge was reached. """
        if self.row == self.matrix.rows:
            ui.message("End of column.")
        else:
            self.row+=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_previousRow(self, gesture):
        """Decreases the row count by 1 if possible, speaking the new row, or speaks that the edge was reached. """
        if self.row == 1:
            ui.message("beginning of column.")
        else:
            self.row-=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_nextColumn(self, gesture):
        """ Increases the column count by 1 if possible, speaking the new column, or speaks that the edge was reached. """
        if self.column == self.matrix.columns:
            ui.message("End of row.")
        else:
            self.column+=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_previousColumn(self, gesture):
        """ Increases the column count by 1 if possible, speaking the new column, or speaks that the edge was reached. """
        import tones;tones.beep(500,55);print "testing"
        if self.column == 1:
            ui.message("Beginning of row.")
        else:
            self.column-=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_deleteMatrix(self, gesture):
        if self.next is None and self.previous is None:
            #last matrix in browser. Clean up.
            self.parent.curMatrix = self.parent.firstMatrix = self.parent.lastMatrix = None
        elif self.next is None:
            self.previous.next = None
            self.parent.curMatrix = self.parent.firstMatrix
            self.parent.lastMatrix = self.previous
        elif self.previous is None:
            self.next.previous = None
            self.parent.firstMatrix = self.parent.curMatrix = self.next
        else:
            self.previous.next = self.next
            self.next.previous = self.previous
            self.parent.curMatrix = self.next
        #Scilently renumber all matrices
        num=self.matrixNumber
        matrix = self.next
        while matrix:
            matrix.matrixNumber = num
            num+=1
            matrix = matrix.next
        self.parent.curMatrix.setFocus()
        del self

    def isOnlyMatrix(self):
        return not (self.next or  self.previous)

    def script_nextMatrix(self, gesture):
        if self.isOnlyMatrix():
            ui.message("There is only one matrix currently loaded.")
            return
        ui.message("Switching to next matrix")
        self.parent.curMatrix = (self.next if self.next else self.parent.firstMatrix)
        self.parent.curMatrix.setFocus()
    script_nextMatrix.__doc__ = "Goes to the next matrix in the browser if possible."

    def script_previousMatrix(self, gesture):
        if self.isOnlyMatrix():
            ui.message("There is only one matrix currently loaded.")
            return
        ui.message("Switching to previous matrix")
        self.parent.curMatrix = (self.previous if self.previous else self.parent.lastMatrix)
        self.parent.curMatrix.setFocus()
    script_previousMatrix.__doc__ = "Goes to the previous matrix in the browser if possible."

    __gestures = {
        "kb:upArrow" : "previousRow",
        "kb:downArrow" : "nextRow",
        "kb:leftArrow" : "previousColumn",
        "kb:rightArrow" : "nextColumn",
        "kb:tab" : "nextMatrix",
        "kb:shift+tab" : "previousMatrix",
        "kb:delete" : "deleteMatrix",
    }
--

Derek Riemer

  • Department of computer science, third year undergraduate student.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Member of Bridge Cu
  • Avid skiier.

Websites:
Honors portfolio
Awesome little hand built weather app!

[hidden email]
Phone: <a moz-do-not-send="true" href="tel:%28303%29%20906-2194" value="+13039062194" target="_blank">(303) 906-2194


------------------------------------------------------------------------------

_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel




------------------------------------------------------------------------------


_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel

--

Derek Riemer

  • Department of computer science, third year undergraduate student.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Member of Bridge Cu
  • Avid skiier.

Websites:
Honors portfolio
Awesome little hand built weather app!

[hidden email]
Phone: (303) 906-2194


------------------------------------------------------------------------------

_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: use of getScript

James Teh
In reply to this post by derek riemer
So either you *are* still focused on that edit field or you've somehow ended up with that class in the overlay classes for your fake NVDAObject.

On Tue, Nov 22, 2016 at 9:56 AM, derek riemer <[hidden email]> wrote:

Input help: gesture kb(laptop):downArrow, bound to script reportLineOverflow on appModules.notepad++.editWindow.EditWindow

but I'm no longer focused on that edit field.


On 11/21/2016 4:51 PM, James Teh wrote:
What you're doing should work. Maybe the arrow keys are being overridden by an unintentional overlay class or something? Or a TreeInterceptor? Does input help logging report that the arrows are bound to something when you press them?

I used getScript for MathPlayer because I wanted to pass pretty much all keystrokes to MathPlayer without having to manually bind every one of them, especially since MathPlayer is basically just a black box to us; we can't access its key map or anything like that.


On Tue, Nov 22, 2016 at 9:06 AM, derek riemer <[hidden email]> wrote:

Why is getScript used in the mathPlayer class? I figured binding gestures would work fine for my latex-access overlay class which is done in edit fields and allows you to move through matrices, but only the tab and shift tab scripts do. The arrows just don't do anything.

The class is below.
class MatrixBrowserNVDAObject(MathInteractionNVDAObject):
    """
    An NVDA object allowing for navigation through matrices.
    Pressing tab and shift+tab focus the next and previous matrix.
    Pressing arrow keys allow for movement around this matrix.
    """
   
    def __init__(self, provider=None, latex=None, cur=None, matrixNumber=0):
        super(MatrixBrowserNVDAObject, self).__init__(provider=provider)
        self.matrix=latex_access.matrix_processor.matrix()
        self.matrix.tex_init(latex )
        # The msg variable is here to say how many rows and columns have been initialised.
        msg = _("Initialised")
        msg = msg + str (self.matrix.rows)
        msg = msg + _(" by ")
        msg = msg + str(self.matrix.columns)
        msg = msg +_( " matrix")
        ui.message (msg)
        self.matrixNumber = matrixNumber
        self.row=1
        self.column=1
        self.previous = cur
        self.next = None

    def create(self, latex):
        if self.next is not None:
            raise ValueError("You must only create a matrix at the end of the set")
        self.next = MatrixBrowserNVDAObject(latex = latex, cur=self, matrixNumber = self.matrixNumber+1)
        return self.next

    def speakMatrix(self):
        matrix=[
            "Matrix %d" % self.matrixNumber,
            "Begin matrix",
            speech.BreakCommand(400)]
        for i in range(1, self.matrix.rows+1) :
            matrix+=self.speakRow(i)
            matrix.append(speech.BreakCommand(300))
        speech.speak(matrix+["end matrix"])

    def speakRow(self, row):
        temp = ["row "+str(row)+": ",
            speech.BreakCommand(300)]
        temp.append(speech.PitchCommand(1.25))
        for i in xrange(1,self.matrix.columns+1):
            temp+=[str(self.matrix.get_cell(row,i)), speech.BreakCommand(180)]
        temp.append(speech.PitchCommand(0.25))
        return temp

    def event_gainFocus(self):
        self.speakMatrix()

    def script_nextRow(self, gesture):
        """ Increases the row count by 1 if possible, speaking the new row, or speaks that the edge was reached. """
        if self.row == self.matrix.rows:
            ui.message("End of column.")
        else:
            self.row+=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_previousRow(self, gesture):
        """Decreases the row count by 1 if possible, speaking the new row, or speaks that the edge was reached. """
        if self.row == 1:
            ui.message("beginning of column.")
        else:
            self.row-=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_nextColumn(self, gesture):
        """ Increases the column count by 1 if possible, speaking the new column, or speaks that the edge was reached. """
        if self.column == self.matrix.columns:
            ui.message("End of row.")
        else:
            self.column+=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_previousColumn(self, gesture):
        """ Increases the column count by 1 if possible, speaking the new column, or speaks that the edge was reached. """
        import tones;tones.beep(500,55);print "testing"
        if self.column == 1:
            ui.message("Beginning of row.")
        else:
            self.column-=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_deleteMatrix(self, gesture):
        if self.next is None and self.previous is None:
            #last matrix in browser. Clean up.
            self.parent.curMatrix = self.parent.firstMatrix = self.parent.lastMatrix = None
        elif self.next is None:
            self.previous.next = None
            self.parent.curMatrix = self.parent.firstMatrix
            self.parent.lastMatrix = self.previous
        elif self.previous is None:
            self.next.previous = None
            self.parent.firstMatrix = self.parent.curMatrix = self.next
        else:
            self.previous.next = self.next
            self.next.previous = self.previous
            self.parent.curMatrix = self.next
        #Scilently renumber all matrices
        num=self.matrixNumber
        matrix = self.next
        while matrix:
            matrix.matrixNumber = num
            num+=1
            matrix = matrix.next
        self.parent.curMatrix.setFocus()
        del self

    def isOnlyMatrix(self):
        return not (self.next or  self.previous)

    def script_nextMatrix(self, gesture):
        if self.isOnlyMatrix():
            ui.message("There is only one matrix currently loaded.")
            return
        ui.message("Switching to next matrix")
        self.parent.curMatrix = (self.next if self.next else self.parent.firstMatrix)
        self.parent.curMatrix.setFocus()
    script_nextMatrix.__doc__ = "Goes to the next matrix in the browser if possible."

    def script_previousMatrix(self, gesture):
        if self.isOnlyMatrix():
            ui.message("There is only one matrix currently loaded.")
            return
        ui.message("Switching to previous matrix")
        self.parent.curMatrix = (self.previous if self.previous else self.parent.lastMatrix)
        self.parent.curMatrix.setFocus()
    script_previousMatrix.__doc__ = "Goes to the previous matrix in the browser if possible."

    __gestures = {
        "kb:upArrow" : "previousRow",
        "kb:downArrow" : "nextRow",
        "kb:leftArrow" : "previousColumn",
        "kb:rightArrow" : "nextColumn",
        "kb:tab" : "nextMatrix",
        "kb:shift+tab" : "previousMatrix",
        "kb:delete" : "deleteMatrix",
    }
--

Derek Riemer

  • Department of computer science, third year undergraduate student.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Member of Bridge Cu
  • Avid skiier.

Websites:
Honors portfolio
Awesome little hand built weather app!

[hidden email]
Phone: <a href="tel:%28303%29%20906-2194" value="+13039062194" target="_blank">(303) 906-2194


------------------------------------------------------------------------------

_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel




------------------------------------------------------------------------------


_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel

--

Derek Riemer

  • Department of computer science, third year undergraduate student.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Member of Bridge Cu
  • Avid skiier.

Websites:
Honors portfolio
Awesome little hand built weather app!

[hidden email]
Phone: <a href="tel:%28303%29%20906-2194" value="+13039062194" target="_blank">(303) 906-2194


------------------------------------------------------------------------------

_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel



------------------------------------------------------------------------------

_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: use of getScript

derek riemer

After working through my issue with this with Jamie on the IRC channel, I discovered that other appModules and plugins were having the overlay's added to it. To fix this I did two things.

1. In the global plugin, I was more careful about instanciating an edit field overlay.

2. I nuked the windowClassName because scintilla and possibly other controls don't play nice with that.

The only remaining problem has to do with the following.

Wen I move from one matrix to the next, it reads off the title bar of the matrix whose window handle was used as the parent (These matrices are stored as pointers via a static variable. (I did this because any user should be able to read off all the matrices, no matter the edit field they are in, however didn't expect tabbing from one to the next (tab moves to the next child) to read off the title bar of that app. How does NVDA fetch the title bar to read this, and is there a way to squelch it? Also, is this not the best way to implement a virtual matrix browser? I did it using NVDAObjects because it allows a clean way to implement arrow keys moving through a matrix without the issue of tying to rebind every gesture map that existed prior.
Thanks.
To reiterate the class variable thing, I am going to show the stub for my class.

class EditableLatex(NVDAObjects.behaviors.EditableText):

    processMaths = False
    latex_access = latex_access.latex_access_com.latex_access_com()
    _firstMatrix=None#points at an NVDAObject
    _curMatrix=None#points at the NVDAObject representing the currently selected matrix
    _lastMatrix=None#points at an NVDAObject

    def _get_firstMatrix(self):
        return EditableLatex._firstMatrix

    def _set_firstMatrix(self, value):
        EditableLatex._firstMatrix = value

    def _get_lastMatrix(self):
        return EditableLatex._lastMatrix

    def _set_lastMatrix(self, value):
        EditableLatex._lastMatrix = value

    def _get_curMatrix(self):
        return EditableLatex._curMatrix

    def _set_curMatrix(self, value):
        EditableLatex._curMatrix = value
---Class in matrix Browser in previous email hasn't changed a ton.


On 11/21/2016 4:59 PM, James Teh wrote:
So either you *are* still focused on that edit field or you've somehow ended up with that class in the overlay classes for your fake NVDAObject.

On Tue, Nov 22, 2016 at 9:56 AM, derek riemer <[hidden email]> wrote:

Input help: gesture kb(laptop):downArrow, bound to script reportLineOverflow on appModules.notepad++.editWindow.EditWindow

but I'm no longer focused on that edit field.


On 11/21/2016 4:51 PM, James Teh wrote:
What you're doing should work. Maybe the arrow keys are being overridden by an unintentional overlay class or something? Or a TreeInterceptor? Does input help logging report that the arrows are bound to something when you press them?

I used getScript for MathPlayer because I wanted to pass pretty much all keystrokes to MathPlayer without having to manually bind every one of them, especially since MathPlayer is basically just a black box to us; we can't access its key map or anything like that.


On Tue, Nov 22, 2016 at 9:06 AM, derek riemer <[hidden email]> wrote:

Why is getScript used in the mathPlayer class? I figured binding gestures would work fine for my latex-access overlay class which is done in edit fields and allows you to move through matrices, but only the tab and shift tab scripts do. The arrows just don't do anything.

The class is below.
class MatrixBrowserNVDAObject(MathInteractionNVDAObject):
    """
    An NVDA object allowing for navigation through matrices.
    Pressing tab and shift+tab focus the next and previous matrix.
    Pressing arrow keys allow for movement around this matrix.
    """
   
    def __init__(self, provider=None, latex=None, cur=None, matrixNumber=0):
        super(MatrixBrowserNVDAObject, self).__init__(provider=provider)
        self.matrix=latex_access.matrix_processor.matrix()
        self.matrix.tex_init(latex )
        # The msg variable is here to say how many rows and columns have been initialised.
        msg = _("Initialised")
        msg = msg + str (self.matrix.rows)
        msg = msg + _(" by ")
        msg = msg + str(self.matrix.columns)
        msg = msg +_( " matrix")
        ui.message (msg)
        self.matrixNumber = matrixNumber
        self.row=1
        self.column=1
        self.previous = cur
        self.next = None

    def create(self, latex):
        if self.next is not None:
            raise ValueError("You must only create a matrix at the end of the set")
        self.next = MatrixBrowserNVDAObject(latex = latex, cur=self, matrixNumber = self.matrixNumber+1)
        return self.next

    def speakMatrix(self):
        matrix=[
            "Matrix %d" % self.matrixNumber,
            "Begin matrix",
            speech.BreakCommand(400)]
        for i in range(1, self.matrix.rows+1) :
            matrix+=self.speakRow(i)
            matrix.append(speech.BreakCommand(300))
        speech.speak(matrix+["end matrix"])

    def speakRow(self, row):
        temp = ["row "+str(row)+": ",
            speech.BreakCommand(300)]
        temp.append(speech.PitchCommand(1.25))
        for i in xrange(1,self.matrix.columns+1):
            temp+=[str(self.matrix.get_cell(row,i)), speech.BreakCommand(180)]
        temp.append(speech.PitchCommand(0.25))
        return temp

    def event_gainFocus(self):
        self.speakMatrix()

    def script_nextRow(self, gesture):
        """ Increases the row count by 1 if possible, speaking the new row, or speaks that the edge was reached. """
        if self.row == self.matrix.rows:
            ui.message("End of column.")
        else:
            self.row+=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_previousRow(self, gesture):
        """Decreases the row count by 1 if possible, speaking the new row, or speaks that the edge was reached. """
        if self.row == 1:
            ui.message("beginning of column.")
        else:
            self.row-=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_nextColumn(self, gesture):
        """ Increases the column count by 1 if possible, speaking the new column, or speaks that the edge was reached. """
        if self.column == self.matrix.columns:
            ui.message("End of row.")
        else:
            self.column+=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_previousColumn(self, gesture):
        """ Increases the column count by 1 if possible, speaking the new column, or speaks that the edge was reached. """
        import tones;tones.beep(500,55);print "testing"
        if self.column == 1:
            ui.message("Beginning of row.")
        else:
            self.column-=1
            ui.message (self.matrix.get_cell(self.row, self.column))

    def script_deleteMatrix(self, gesture):
        if self.next is None and self.previous is None:
            #last matrix in browser. Clean up.
            self.parent.curMatrix = self.parent.firstMatrix = self.parent.lastMatrix = None
        elif self.next is None:
            self.previous.next = None
            self.parent.curMatrix = self.parent.firstMatrix
            self.parent.lastMatrix = self.previous
        elif self.previous is None:
            self.next.previous = None
            self.parent.firstMatrix = self.parent.curMatrix = self.next
        else:
            self.previous.next = self.next
            self.next.previous = self.previous
            self.parent.curMatrix = self.next
        #Scilently renumber all matrices
        num=self.matrixNumber
        matrix = self.next
        while matrix:
            matrix.matrixNumber = num
            num+=1
            matrix = matrix.next
        self.parent.curMatrix.setFocus()
        del self

    def isOnlyMatrix(self):
        return not (self.next or  self.previous)

    def script_nextMatrix(self, gesture):
        if self.isOnlyMatrix():
            ui.message("There is only one matrix currently loaded.")
            return
        ui.message("Switching to next matrix")
        self.parent.curMatrix = (self.next if self.next else self.parent.firstMatrix)
        self.parent.curMatrix.setFocus()
    script_nextMatrix.__doc__ = "Goes to the next matrix in the browser if possible."

    def script_previousMatrix(self, gesture):
        if self.isOnlyMatrix():
            ui.message("There is only one matrix currently loaded.")
            return
        ui.message("Switching to previous matrix")
        self.parent.curMatrix = (self.previous if self.previous else self.parent.lastMatrix)
        self.parent.curMatrix.setFocus()
    script_previousMatrix.__doc__ = "Goes to the previous matrix in the browser if possible."

    __gestures = {
        "kb:upArrow" : "previousRow",
        "kb:downArrow" : "nextRow",
        "kb:leftArrow" : "previousColumn",
        "kb:rightArrow" : "nextColumn",
        "kb:tab" : "nextMatrix",
        "kb:shift+tab" : "previousMatrix",
        "kb:delete" : "deleteMatrix",
    }
--

Derek Riemer

  • Department of computer science, third year undergraduate student.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Member of Bridge Cu
  • Avid skiier.

Websites:
Honors portfolio
Awesome little hand built weather app!

[hidden email]
Phone: <a moz-do-not-send="true" href="tel:%28303%29%20906-2194" value="+13039062194" target="_blank">(303) 906-2194


------------------------------------------------------------------------------

_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel




------------------------------------------------------------------------------
_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel
--

Derek Riemer

  • Department of computer science, third year undergraduate student.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Member of Bridge Cu
  • Avid skiier.

Websites: Honors portfolio Awesome little hand built weather app!

[hidden email] Phone: <a moz-do-not-send="true" href="tel:%28303%29%20906-2194" value="+13039062194" target="_blank">(303) 906-2194

------------------------------------------------------------------------------ _______________________________________________ Nvda-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/nvda-devel
------------------------------------------------------------------------------
_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel
--

Derek Riemer

  • Department of computer science, third year undergraduate student.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Member of Bridge Cu
  • Avid skiier.

Websites: Honors portfolio Awesome little hand built weather app!

[hidden email] Phone: (303) 906-2194


------------------------------------------------------------------------------

_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel
Loading...