Create a toolbar
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Create a toolbar
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?
			
			
									
									
						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
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
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'
			
			
									
									
						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
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.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..
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?
- Attachments
- 
			
		
				- 545454.png (13.96 KiB) Viewed 14674 times
 
Re: Create a toolbar
Hi Mag,
load the attached image and set it as the FILL pattern for a button, like I did in one of my projects 
 
It is actually a screenshot from a "real" OS X toolbar.
Best
Klaus
			
							load the attached image and set it as the FILL pattern for a button, like I did in one of my projects
 
 It is actually a screenshot from a "real" OS X toolbar.
Best
Klaus
- Attachments
- 
			
		
				- top_bar.jpg (5.02 KiB) Viewed 14661 times
 
Re: Create a toolbar
Thank you so much Klaus!
PS
Somebody has a retina Mac so to take a screen of the @2x version?
			
			
									
									
						PS
Somebody has a retina Mac so to take a screen of the @2x version?

Re: Create a toolbar
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
					Last edited by Mag on Thu Mar 07, 2013 5:30 pm, edited 1 time in total.
									
			
									
						Re: Create a toolbar
Mag, try…
Paul
			
			
									
									
						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 mouseUpRe: Create a toolbar
HI all,
or even shorter 
 
Hint: No LOCK/UNLOCK SCREEN necessary!
Best
Klaus
			
			
									
									
						or even shorter
 
 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 mousereleaseKlaus
Re: Create a toolbar
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:
			
							
			
									
									
						Here is a picture of the current version:
Re: Create a toolbar
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
Wow! Very impressive!!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:

Re: Create a toolbar
Thank you Paul!
And for Retina I guess I have to double that value...
			
			
									
									
						And for Retina I guess I have to double that value...
Re: Create a toolbar
Hi Mag,
Best
Klaus
			
			
									
									
						sorry, my fault, a little typo, change the "mousemove" handler to: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
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 mouseMoveKlaus
Re: Create a toolbar
Hi Klaus, this works well, thanks.Klaus wrote:Hi Mag,sorry, my fault, a little typo, change the "mousemove" handler to: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 89BestCode: 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
Klaus
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).
