macoslib toolbar search field

  1. 4 years ago

    Hi,
    Does anyone know the steps necessary to add an NSSearchField to my already existing toolbar?
    I have looked at the corresponding window in the macoslib examples folder, but cannot work out how to add a search field into my already existing toolbar.

    Thank you.

  2. 3 years ago

    Jean-Yves P

    7 Sep 2014 Pre-Release Testers, Xojo Pro Europe (France, Besancon)

    I'm looking for that too ... bumping the conversation !

  3. Michel B

    7 Sep 2014 Pre-Release Testers, Xojo Pro

    I lifted this from an example project Jim McKay posted in the black window thread. If you place it in the Open event of the window, it will enable you to place regular controls over the toolbar :

      declare function contentView lib "Cocoa" selector "contentView" (id As integer) As Ptr
      declare function superView lib "Cocoa" selector "superview" (id As Ptr) As Ptr
      declare function subviews lib "Cocoa" selector "subviews" (id As Ptr) As Ptr
      declare function objAtIdx lib "Cocoa" selector "objectAtIndex:" (id As Ptr, idx As UInt32) As Ptr
      declare sub addSubView lib "Cocoa" selector "addSubview:positioned:relativeTo:" _
      (id As Ptr, aView As integer, order As integer, rel As Ptr)
      
      dim cv As Ptr = contentView(self.Handle)
      cv.Integer = cv.integer
      dim themeFrame As Ptr = superView(cv)
      dim firstSubView As Ptr = objAtIdx(subViews(themeFrame), 0)
      addSubView(themeFrame, CanvasBar.Handle, 0, firstSubView)
  4. Michel B

    7 Sep 2014 Pre-Release Testers, Xojo Pro
    Edited 3 years ago

    I have used that to create this example :

    -image-

    Note that the two first buttons are toolbar buttons, after which they all are regular controls.

  5. Axel S

    is not verified 7 Sep 2014 Europe (Germany, Erfurt)

    Download Example

    -image-

  6. Sam R

    7 Sep 2014 Pre-Release Testers, Xojo Pro Hengchun, Pingtung, Taiwan

    Hi Michel,
    I would not recommend using this code for this purpose. This code inserts the control into the window frame, what you want is code that inserts the control into the toolbar. This way it'll work on both Mavericks and Yosemite (with the different visual styles).

    I included that code at part of the Yosemite article in the latest xDev magazine, it also comes with the retina kit.

  7. 8 months ago

    Martin T

    20 Apr 2017 Pre-Release Testers

    Hi @Sam R,

    I use your Code from the xDevMag Article where I can add different Controls in to a macOS Toolbar. I added a PushButton. After click on it, the Button should show a PopUp-Menu. I use this sample code, but it opens at the wrong coordinates, not at the coordinates, where the PushButton is placed into the Toolbar Me.setItemControl( 0, PushButton1 ). How to fix it?

    Dim base As New MenuItem
    
    base.append(New MenuItem("Import"))
    base.append(New MenuItem("Export"))
    base.append(New MenuItem(MenuItem.TextSeparator))
    
    base.append(New MenuItem("Cut"))
    base.append(New MenuItem("Copy"))
    base.append(New MenuItem("Paste"))
    
    Dim selectedMenu As MenuItem
    selectedMenu = base.Popup(me.Left, PushButton1.Left, pushButton1.Top + PushButton1.Height) ' PushButtons original Coordinates
  8. Sam R

    20 Apr 2017 Pre-Release Testers, Xojo Pro Hengchun, Pingtung, Taiwan

    @MartinTrippensee I use your Code from the xDevMag Article where I can add different Controls in to a macOS Toolbar. I added a PushButton. After click on it, the Button should show a PopUp-Menu. I use this sample code, but it opens at the wrong coordinates, not at the coordinates, where the PushButton is placed into the Toolbar Me.setItemControl( 0, PushButton1 ). How to fix it?

    1. Don't use a PushButton when you want a drop down menu, see the latest xDev for code on how to make one.
    2. Most of the stuff I do, messes with the Xojo view hierarchy.
    3. You could grab the X and Y co-ordinates from the MouseDown event and subtract them from the system mouse location.
    base.popup( system.mouseX - X, system.mouseY - Y )
  9. Martin T

    20 Apr 2017 Pre-Release Testers

    Thanks Sam.

    Have a look to Apple Pages. If you click the View Toolbutton, you see a Popupmenu. Is this the same you describe in the current xDevMag?

  10. Sam R

    20 Apr 2017 Pre-Release Testers, Xojo Pro Hengchun, Pingtung, Taiwan

    @MartinTrippensee Thanks Sam.

    Have a look to Apple Pages. If you click the View Toolbutton, you see a Popupmenu. Is this the same you describe in the current xDevMag?

    Yup.

  11. Martin T

    20 Apr 2017 Pre-Release Testers
    Edited 8 months ago

    And how can I style the Popupmenu like a PushButton/SegmentedControl? And how to set a image to this?

  12. Sam R

    20 Apr 2017 Pre-Release Testers, Xojo Pro Hengchun, Pingtung, Taiwan

    @MartinTrippensee And how can I style the Popupmenu like a PushButton/SegmentedControl? And how to set a image to this?

    The article explains how to use the Retina Kit to add images/icons to the popup menu.

    As for the style; once you have the Retina Kit installed in your project you can call.

    me.setBezelStyle NSBezelStyle.texturedRounded

    In the open event of the PopupMenu.

  13. Martin T

    22 Apr 2017 Pre-Release Testers

    Hi,

    I built a small Sample-Project with Sam's Code for xDevMag on macOS Sierra 10.12.4. I added a PopupMenu to the Toolbar (Zoom). If I open the App, there is a big distance between the PopupMenu und the ToolButtons Text. After resizing the Window to Fullscreen-Mode, the PopupMenu and Text placed well. How to fix it?

    After App opened

    -image-

    After App resized to Fullscreen-Mode

    -image-

    Sample-Project

  14. Christoph D

    22 Apr 2017 Pre-Release Testers, Xojo Pro

    Without testing (but it will work). Change the height of popupmenu to 34 or more. That should take care of the alignment.
    Not sure if this is a Xojo bug, but it fixes such issues.

  15. Martin T

    22 Apr 2017 Pre-Release Testers

    @Christoph Dnbsp;Vocht Without testing (but it will work). Change the height of popupmenu to 34 or more. That should take care of the alignment.
    Not sure if this is a Xojo bug, but it fixes such issues.

    Simple solution. It works fine! Thank you Christoph

or Sign Up to reply!