def handle_to_x(self, mouse_x):
        """Position handle according to mouse x coordinate.

        Parameters
        ==========
        mouse_x (integer)
            mouse x coordinate relative to screen and
            constrained to it.
        """
        ### clamp mouse_x to selection area width

        ## retrieve selection area horizontal edges

        left = self.selection_area.left
        right = self.selection_area.right

        ## clamp
        clamped_x = max(left, min(right, mouse_x))

        ### position handle
        self.handle.rect.centerx = clamped_x
Position handle according to mouse x coordinate.

        Parameters
        ==========
        mouse_x (integer)
            mouse x coordinate relative to screen and
            constrained to it.
        
nodezator/our3rdlibs/scale.py