Possible bug - Canvas Clip Mouse doesn't clip

Mac OSX specific forum
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Possible bug - Canvas Clip Mouse doesn't clip

Post by davido »

In the code below #PB_Canvas_ClipMouse and #PB_Canvas_Clip do not seem to work.
Can any one confirm, please.

Tested on:

MacBook Pro - Mavericks PB 5.22 LTS - Does not appear to work.
Windows 7 64 bit with PB 5.22 LTS - Works
Linux Mint 16 64 bit with PB 5.22 LTS - Works

Window 7 64 bit with PB 5.30 Beta 2 - Works

Code: Select all

 ; As we embedded xml directly in the source, the encoding of special characters will vary if we are in unicode mode or not. 
  ; So ensure to use the correct one. This is not needed if the XML is read from an external file or directly included
  ; with IncludeBinary.
  ;
  CompilerIf #PB_Compiler_Unicode
    #XmlEncoding = #PB_UTF8
  CompilerElse 
    #XmlEncoding = #PB_Ascii
  CompilerEndIf

  #Dialog = 0
  #Xml = 0
  
  Runtime Enumeration Gadget
    #ListView
    #GeneralContainer
    #EditorContainer
    #BackupContainer
  EndEnumeration
  
  
  Structure SliderData
    Len.w
    Text$
    PixelWidth.W
    PicsPerPixel.w
    LSpaces.w
    RSpaces.w
  EndStructure
  
  
  
  Runtime Procedure EventSlider()
    Protected Slider.SliderData
    Static PPos.w, Picxx.w
    Width = GadgetWidth(10)
    Select EventType()
      Case #PB_EventType_MouseLeave
        StartDrawing(CanvasOutput(10))
        Box(0,0,Width,25,$ffffff)
        DrawText(70,3,"Choose approximate picture with mouse - click To Select",0,$fefefe)
        SetGadgetAttribute(10,#PB_Canvas_Cursor,#PB_Cursor_Default)
        StopDrawing()
        ProcedureReturn 
      Case  #PB_EventType_MouseEnter
        StartDrawing(CanvasOutput(10))
        Box(0,0,Width,25,$ffffff)
        SetGadgetAttribute(10,#PB_Canvas_Cursor,#PB_Cursor_Cross)
        StopDrawing()
        
      Case #PB_EventType_LeftClick
        Debug "Picture: " + Str(Picxx)
        SetGadgetAttribute(10,#PB_Canvas_Clip,0)
    EndSelect
      HalfWay = Width >> 1
      PPos = GetGadgetAttribute(10,#PB_Canvas_MouseX)

      
      StartDrawing(CanvasOutput(10))
      SetGadgetAttribute(10,#PB_Canvas_Clip,0)
      Picxx = (4855 * PPos) / Width
      If PPos <= 0
        Picxx = 1
      EndIf
      If PPos < 20
        SetGadgetAttribute(10,#PB_Canvas_Clip,1)
      EndIf
      If PPos >= Width - 20
        SetGadgetAttribute(10,#PB_Canvas_Clip,1)
      EndIf
      If PPos >= Width 
        Picxx = 4855
      EndIf
      T$ = " " + Str(Picxx) + " "
      Tlen = TextWidth(T$)
      MidTlen = Tlen >> 1
      If PPos > HalfWay
        St = PPos - 26 - Tlen
      Else
        St = PPos + 20
      EndIf
      Box(0,0,Width,25,$ffffff)
      RoundBox(St,3,6 + TextWidth(T$),20,5,5,$ceccca)
      DrawText(St + 3,5,T$,0,$ffffff)
      StopDrawing()
      
    
  EndProcedure
  
  XML$ = "<window id='0' name='test' text='Photograph Cataloguer' minwidth='auto' minheight='auto' " +
         "flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
         "<hbox>" +
         "  <vbox>" +
         "    <container id='#GeneralContainer' width='520' height='650' >" +
         "    <vbox>" +
         "    <canvas text='editor' id='10' width='520' height='25' onEvent='EventSlider()' flags='#PB_Canvas_Keyboard | #PB_Canvas_ClipMouse'>" +
         "    </canvas>" +
         "    <empty height='105' />" +
         "    <canvas text='Canvas' id='11' width='520' height='520'>" +
         "    </canvas>" +
         "    </vbox>" +
         "    </container>" +
         "  </vbox>" +
         "  <vbox expand='item:1'>" +
         "    <container id='#xContainer' width='650' height='650'>" +
         "    <frame text='Editor'>" +
         "    </frame>" +
         "    </container>" +
         "  </vbox>" +
         "</hbox>" +
         "</window>"
  
  If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
    
    If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
      

      Debug "Canvas dimensions: " + Str(GadgetWidth(10)) + "," + Str(GadgetHeight(10))
        StartDrawing(CanvasOutput(10))
        Box(0,0,Width,25,$ffffff)
        DrawText(70,3,"Choose approximate picture with mouse - click To Select",0,$fefefe)
        StopDrawing()
      
      Repeat
        ;Debug Str(WindowMouseX(0)) + " - " + Str(WindowMouseY(0))
        Event = WaitWindowEvent()
      Until Event = #PB_Event_CloseWindow 
      
    Else  
      Debug "Dialog error: " + DialogError(#Dialog)
    EndIf
  Else
    Debug "XML error: " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
  EndIf
  

  
DE AA EB
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Possible bug - Canvas Clip Mouse doesn't clip

Post by J. Baker »

It says in the manual that #PB_Canvas_ClipMouse is not supported on OS X.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Possible bug - Canvas Clip Mouse doesn't clip

Post by davido »

@J Baker,

Thank you very much.

I did read the manual. Don't know how I missed this. :oops:
DE AA EB
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Possible bug - Canvas Clip Mouse doesn't clip

Post by J. Baker »

davido wrote:@J Baker,

Thank you very much.

I did read the manual. Don't know how I missed this. :oops:
No worries, there's a lot to read. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
coder14
Enthusiast
Enthusiast
Posts: 327
Joined: Tue Jun 21, 2011 10:39 am

Re: Possible bug - Canvas Clip Mouse doesn't clip

Post by coder14 »

J. Baker wrote:It says in the manual that #PB_Canvas_ClipMouse is not supported on OS X.
:cry:

Is this a restriction by Mac OS-X or can we still do it via some API call?
Post Reply