Page 1 of 2

Create a toolbar

Posted: Thu Feb 28, 2013 1:57 am
by Mag
As there is no support for the OS X toolbar, I decided to create one using a graphic object and buttons.

Does anyone have advice for me for the artwork, I would use a button with an icon containing a image gradient. it is possible to use as icon in a button that acts as a pattern that repeats itself?

Second, as we know with the toolbar, you can drag the window, this is achievable?

Re: Create a toolbar

Posted: Thu Feb 28, 2013 7:15 am
by shaosean
If they would set the "composite" flag of the windows to true (this can only be done when the window is created and cannot be changed afterwards so cannot achieve it with an external) then it would be trivial to create toolbars for Mac OS X..

Re: Create a toolbar

Posted: Thu Feb 28, 2013 12:42 pm
by ibe
Dragging the window is simple. If your toolbar is for example a rectangle, just add a dragging script to it. You can cut and copy the code from the 'How to make a stack with a window shape' lesson on the RunRev site:
http://lessons.runrev.com/s/lessons/m/4 ... ndow-shape
Look for the code in the chapter 'Add script to move your new stack'

Re: Create a toolbar

Posted: Fri Mar 01, 2013 1:50 pm
by Mag
shaosean wrote:If they would set the "composite" flag of the windows to true (this can only be done when the window is created and cannot be changed afterwards so cannot achieve it with an external) then it would be trivial to create toolbars for Mac OS X..
I shaosean, thank you for the message, I will try to just to add it below the real titlebar (see picture). I know, it's not the state of the art of OS X interface but I seem to recall that at the begin the toolbars are used to be implemented in that way.


Thank you Ibe! It works fine!

Does anyone advise me on how to make a gradient similar to that of the real toolbar using a graphic element with graphic effects?

PS
Or maybe it could it be better to use a button with an image as icon?

Re: Create a toolbar

Posted: Fri Mar 01, 2013 5:31 pm
by Klaus
Hi Mag,

load the attached image and set it as the FILL pattern for a button, like I did in one of my projects :D
It is actually a screenshot from a "real" OS X toolbar.


Best

Klaus

Re: Create a toolbar

Posted: Fri Mar 01, 2013 6:01 pm
by Mag
Thank you so much Klaus!

PS
Somebody has a retina Mac so to take a screen of the @2x version? :oops:

Re: Create a toolbar

Posted: Wed Mar 06, 2013 5:40 pm
by Mag
Al worked great until I create some menus using Menu Builder. If I set the checkbox "Set as stack menu bar" to true, when you drag using the toolbar you see that the window moves by some pixels (as if there where a menubar present in the window, that actually there isn't).

Code: Select all

local sgDragging, sgLeftOffset, sgTopOffset

on mouseDown 
       put item 1 of the mouseLoc into sgLeftOffset 
       put item 2 of the mouseLoc into sgTopOffset 
       put true into sgDragging 
end mouseDown

on mouseMove 
    lock screen
    if sgDragging is true then 
        set the left of this stack to item 1 of globalloc(the mouseLoc) - sgLeftOffset 
        set the top of this stack to item 2 of globalloc(the mouseLoc) - sgTopOffset 
    end if 
    unlock screen 
end mouseMove

on mouseRelease 
    put false into sgDragging 
end mouseRelease

on mouseUp 
    put false into sgDragging 
end mouseUp

Re: Create a toolbar

Posted: Thu Mar 07, 2013 2:44 am
by PBH
Mag, try…

Code: Select all

local sgDragging, sgLeftOffset, sgTopOffset

on mouseDown 
       put item 1 of the mouseLoc into sgLeftOffset 
       put item 2 of the mouseLoc into sgTopOffset 
       put true into sgDragging 
end mouseDown

on mouseMove 
    lock screen
    if sgDragging is true then 
        set the left of this stack to item 1 of globalloc(the mouseLoc) - sgLeftOffset 
        set the top of this stack to item 2 of globalloc(the mouseLoc) - sgTopOffset +22 ## Allowance for MenuBar
    end if 
    unlock screen 
end mouseMove

on mouseRelease 
    put false into sgDragging 
end mouseRelease

on mouseUp 
    put false into sgDragging 
end mouseUp
Paul

Re: Create a toolbar

Posted: Thu Mar 07, 2013 12:07 pm
by Klaus
HI all,

or even shorter :D

Hint: No LOCK/UNLOCK SCREEN necessary!

Code: Select all

local maydrag

on mouseDown
  put mouseH() & "," & mouseV() into maydrag
end mouseDown

on mouseMove
  if maydrag is not empty then
    set the topLeft of this stack to (item 1 of the screenMouseLoc - item 1 of maydrag),()item 2 of the screenMouseLoc - item 2 of maydrag
  end if
end mouseMove

on mouseUp
  put empty into maydrag
end mouseUp

on mouserelease
  mouseup
end mouserelease
Best

Klaus

Re: Create a toolbar

Posted: Thu Mar 07, 2013 4:04 pm
by ibe
I've been playing around with implementing a toolbar and have an almost workable solution. The project description and source code can be found at http://bergroth.on-rev.com/ibTools/styled-3/index.html

Here is a picture of the current version:

Re: Create a toolbar

Posted: Thu Mar 07, 2013 5:29 pm
by Mag
Thank you Klaus, I'm trying to implement it but I get this error:
button "toolbarButton": compilation error at line 10 (Expression: missing factor) near ")", char 89

Re: Create a toolbar

Posted: Thu Mar 07, 2013 5:30 pm
by Mag
ibe wrote:I've been playing around with implementing a toolbar and have an almost workable solution. The project description and source code can be found at http://bergroth.on-rev.com/ibTools/styled-3/index.html

Here is a picture of the current version:
Wow! Very impressive!! :shock:

Re: Create a toolbar

Posted: Thu Mar 07, 2013 5:31 pm
by Mag
Thank you Paul!

And for Retina I guess I have to double that value...

Re: Create a toolbar

Posted: Thu Mar 07, 2013 5:48 pm
by Klaus
Hi Mag,
Mag wrote:Thank you Klaus, I'm trying to implement it but I get this error:
button "toolbarButton": compilation error at line 10 (Expression: missing factor) near ")", char 89
sorry, my fault, a little typo, change the "mousemove" handler to:

Code: Select all

on mouseMove
  if maydrag is not empty then
    set the topLeft of this stack to (item 1 of the screenMouseLoc - item 1 of maydrag),(item 2 of the screenMouseLoc - item 2 of maydrag)
  end if
end mouseMove
Best

Klaus

Re: Create a toolbar

Posted: Thu Mar 07, 2013 8:56 pm
by Mag
Klaus wrote:Hi Mag,
Mag wrote:Thank you Klaus, I'm trying to implement it but I get this error:
button "toolbarButton": compilation error at line 10 (Expression: missing factor) near ")", char 89
sorry, my fault, a little typo, change the "mousemove" handler to:

Code: Select all

on mouseMove
  if maydrag is not empty then
    set the topLeft of this stack to (item 1 of the screenMouseLoc - item 1 of maydrag),(item 2 of the screenMouseLoc - item 2 of maydrag)
  end if
end mouseMove
Best

Klaus
Hi Klaus, this works well, thanks.

PS
This also have the problem that jumps of 22 pixels due that thinks that there is a menubar in the window (but there is not).