semi-transparent panel that doesn't pass mouse events to objects below?
I am trying to put a semi-transparent colored panel in front of other user interface objects so that those other objects are visible behind the panel, but do not respond to mouse clicks. It seems that using the panel object won’t work, as it passes those mouse clicks to objects behind it. I also don’t want to send "ignore mouse click" messages to all the UI objects behind the panel (there’s tons of them). I took a look at lcd, but couldn’t figure out a way to get it to draw with an alpha of anything other than 1.0. I’d also like to avoid using jit.lcd if possible.
You can set the "ignore click" function for all your objects at the same time. Just select them all and press command+i. This will open the "multiple objects inspector". Check "ignore click" and voila…
I’ve done this using thispatcher scripting. Use a ubutton (which doesn’t ignore clicks!) that’s not connecting anything, it will steal clicks when it’s in front. Bring the transparent panel forward as well for display purposes. When you want it unlocked, send them all to the back. When locked, bring them to the front. Note the scripting names in the inspector.
This method allows you to make UI things that are editable only when given values are set, using if/then statements, or just by having certain user actions also trigger locking/unlocking (IE, you can’t change the number of channels in a recording file while the recording is taking place, but unlocks when stopped)
Here’s an example:
----------begin_max5_patcher---------- 809.3ocyX0zbaBCD8L9WAC4J0iEFjg1S8OPmomyjoi.jsUCH4BhzzlI+2qj. rkrw.1A6oGhr0G4oce6S6tIuMyxIl8Jtzw9y1OZaY81LKK0RxErZla4jidMI CUpNlSUbEmynNt068BpfhxwpsxXIOWfSN5DaIYDt5.KZVgVkSnYXtBPPyh6J vkXJGwIL5ODnvqMJ.Xw7Et10igpQOwn8Ssninor0qU2uyA7YU71Kvu8jY7DV FqnF2Ey8W4G.bEeAF4C.gh6PBtN16P7jsD5FMywyWyb7WIGWZ7qn4E5dWs8v +yNbMNNwH5FG2CeJ+gPE2RKRjTkOwh+4mVE3HW68YyjCtiLPsCQwY8DlL1eJ CIlzeaPOdiF62R06GBV.hff9Xd8KE3Et+iAodMhDdUDYBKOW.bKUwwuxqWOi j7rMmYKIz1cWyn7RxeULMva90H4azX0LKHXrDbGbleCcAOKTifzVo6Z6EQes ffxtIrYE81vmASGeB9H7IbZ4SJ92BTOgNyXnz5bKWNOZxGfddSFooTgmxFcm 0qqTb92GQVSpOyBTSgDaITIwVpmW6x0WCpT0Xrk2UFynXw0qk5y20c5A7cuo 02qDddkiYcJu11DBCBC87c67a.MyacgvNLZvvnDmwQ04Ov7fn.P3paPgXQaW 4M814jynLYOFtxgRNt.eX5upPoNmQstrqx2imUju8aLgdKtGzumL51pjsP0z MUm4YBCmVoSNtrDsAexylxjBxNtsvnS4rXjnxl9CIW6yt+QMOmQnBQUEUgpW WxgNOwXdg5Mf3ptE25XAPkXao2YSpMbQhFwZWPM5namgTXzcMjFWHbONacg3 x5Nn10I9OKrFNcgU3sJrFdW5ShukTp7NbwD1OP6elRciQQCzwo2frr2YQZ7j 74RIB6qgzlcJQuzhyCeShjAsY67E4vCeWNJxnUuh8SZQI0Eqj8G8OaPAhbcy PWIqpHo8JaZPz9fWmhK4D5dm9wCYBzNzVRZJlp21QNIcGSThXeEoN0Qi0jjJ zgsI3kYSfnn4AxXbfRAoM6iZsQ2NqE3qd8CVo5B1bl2Bngm.OxSDSde1+LJe l0E -----------end_max5_patcher-----------
lcd works fine. You need to set the bgtransparent attribute.
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 477.3ocuUEsSCCBE841uBBwGqK.qst4a9cXLFZKqhRglBKYpw+cAZYqyzoMy oOrdCGtb24b3j12iifEpcLMDbK3dPTz6wQQdHGPzv5HXCcWofp8sAaXZMslA S52yv1Y737ZopiUJ3ku.tBG1diRZz72XtVvjEnAX41FtTvL9QRN.p1ZBn3Az Vpo7Itr9Q6vM8DMEeicR.7xbWYEwuX0BD3ggyzOFyqsr9C.g62hW4Yqp34qy FSRIsw2L7tNNU.ca7Qbr6QxLMFQYUXfBUocFVvfdKpMcTotk1wjlwp6Hi.Oo QjdZi.msxq8buQfIq1WNsUH3ZCL4PkK8kIcH743CmJfTJXztDvlt5B.Bjg.q Q1fRBnkZofSSVTji8te+o4mfs0meHoKOy.D4xFfr7uf0EloUf7lsMiSQywLl NCQ9Yy.4MiLj2RPemWLjXJnx5IskkWVaoxct4K0u6de8Zu5votRJJ77zRciP QMSJxzyQJFUcsfcYDS3kf82ajYduMkTxGKEeC1WNH+5WE7Tvger9zpsckg+g gaevARTwzFtjZ3J4ndHG0yS7pJlbbPugW0przcfBfGlzqmKiHyfQ3+UFkc4Y TJIeQlMNjs1WxuY+peIWymAWy9EtmcwGweRteR+p -----------end_max5_patcher-----------
@MIB – thanks, but I neglected to say that I need to hide/show my obsuring panel programmatically within my app, so the thought of setting/unsetting the ignore clicks attribute on all of my underlying UI objects also programmatically is not a fun one.
@MuShoo – Hah! How quickly one forgets the tricks that we used in Max 4 and previous – the invisible ubutton! Thanks…
@Emmanuel – Ah, now I see – thanks! I was under the impression that the transparent attribute only pertained to the *background* of the LCD (since it is named bgtransparent). I didn’t realize that it would work when painting to the *foreground*. I did the same test that your patch shows, but I was using brgb, not frgb. Perhaps a better name is needed for this attribute? Thanks again.
Don’t worry about ignoreclick, just show/hide the ubutton and the panel programatically with "hidden $1". If they’re on top, the ubutton will steal the clicks as mentioned. Scripting will also work with the bringtofront/sendtoback, but it’s maybe not needed in this case.
So both the ubutton and lcd-with-transparency-on methods work fine, thanks. (Still can’t believe I forgot about ubutton!).
But now the next challenge – I’m not sure this is possible, but I’d like to be able to still capture the scripting names of the "covered up" interface objects, while using hover. See patch below – basically, I also want to be able to capture the name of the dial on the right, just like I can the dial on the left….
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 492.3ocuUF0aBBCDG+Y3SAoOiFZgB5daeNVVVpRU6BzZnkM2V769nGhhNQEC NRnDt1d8te7+39w0AMSsgqQdO48hmiyOtNNfIqAmcu6fxYalmwzvxPoBVFxu dhOXERVNeucbyDpRSF2X9ZMu10nEYJlA485t4EovdTydeTRydVWv0bogYDJ4 aE74l5shSlNNv2CGEXezLr2Sxxbgr5rffCevXcDbj00Ly7UB4x1NeZn0ggw1 w5SHB7tcGaccsC92HXJmUZLJYmHXFStD4e3o8VHaAkULYpZwBvYn+BpXzsmx QcmxjHrMMIPJSSriwg2YJmy0Z1RdSfY3aL2fV3rx.ZyxWnjl8hpmKZo1NJuI sVtV7Mrbr8CXOU.jZ0U..BJn.vw2INj7OqRk+PiUpO3EcSC+V2miLg8jL3yQ F7X5TJdRReUKw.QBgpD5zwzJgSvvRGMOySpj7qV2bV3fIOb5P5lNIQGJhnTn rJXfKkFYu5WoDNZHpktHSvWiISfexDRrJF7j6jIWpUC4NZ0fQCRSCRzDH4nW noAb7nLg7zlqf+r1ONu0pxh4MYvtpdO79jHkqMBIzZr0ZrheuCsBWIRS4v7M +ELWjtVU0iYWLzwGg9DRAWIjnGE1O5H5D.zAkh9WozIG2viopW159K.Xhiy2 -----------end_max5_patcher-----------
I think I’m going to have to rethink things as I don’t think this is possible to do – but maybe you guys will show me otherwise!
My thinking is this: if you’re using a ubutton, and you have a ubutton paired to every UI object – give the ubutton a scripting name, like "Xdial2." You could then either have some scripting/code to tear off the X proceeding the name, or have any of your code that is looking for ‘Dial2’ also respond to ‘XDial2.’
You’d probably have to regexp, or some weird coll lookup table or something to do that, though.
Though, I’d never used hover before – my mind is now racing with possibilities for it! Thanks for that. :D
I suppose another option would be to give all your UI objects a name with a set length (say 5 characters) and then strip anything after that, and name your ubuttons "*****locked"
Thanks – yeah, those would work, but the pain is that I have zillions of UI objects, and i’d rather not have to hook up all those ubuttons. I may just rethink what I was trying to do in the first place!
Thanks for everyone’s help…
Forums > MaxMSP