ZBrushCentral

irritating behavior

hello i having a huge issue with preference :utilities: view keyboard status
the value never reset to 0
i d like to track if ctrl or alt or any key get pressed at the same time we click onto a button/switch button in my plugin.
to make it acts differently. but no way.
the value there is never reset, after starting zbrush the value is by default set to 44
i press ctrl which should give 512, but it give 512 +44.
after you drop a polymesh then press T, the value goes to 116, so if i want to know if ctrl is pressed, i must to know first which was the previous value and substract 512 from it, then it would mean that ctrl is pressed.
what am i doing wrong ? or what wrong with Zbrush ?

same issue on R7 and R8.

Nicolas

edit : damn me, i can’t to edit the topic title to fix it.

another bug :

create a plug with that :
[RoutineDef, LoadDefaultLayout,
[IShowActions,0]
[IConfig,4.8]

[FileNameSetNext, [FileNameResolvePath, “ZBRUSH_ZSTARTUP\UserInterfaceLayouts\legacy4R8_02.cfg”]]
[IPress, “Preferences:Config:Load Ui”]

]

[ISubPalette, “Zplugin:Custom UI”]

[IButton, “Zplugin:Custom UI:Load Legacy Layout”, “Load Sculpting Layout.”,
[RoutineCall, LoadDefaultLayout]
,.25,0.25
]

  1. duplicate legacy4r8.cfg and rename it to legacy4r8_02.cfg

  2. open zbrush, load the plugin , load the legacy4r8_02.cfg, and enter in customize Ui edit mode.

  3. drag and drop the button ui to load the custom layout, and save the custom ui again.

  4. when done, just try to click on the button instance in the custom ui.

  5. take a look at the original location of the button, that last one, should have disappeared tottaly.
    hold CTRL over the button in the custom ui and espceially the button path.
    here it looks like the button has no more parent.

unknown.png
unknown.png

about the first, issue with view keyboard status utility
the only way to know if ctrl or shift or alt are pressed, is to read the current brush
at this moment my code check the brush name, so if it stat with “Mask” then it’s a mask
same for smooth brush.

when i click on the switch button, the keyboard status never take in consideration the key i am pressing.

so this approach below cannot work too;
if value is bigger than 256 then shift is pressed, if bigger than 512 then ctrl is pressed,
if bigger than 768 then shift+ctrl are pressed, etc…
but that just return the single key value ( the last)
default : 44
or 116 for example if you pressed T to enter in edit mode.

Hi Nicolas,

You can check which modifier key (or keys) is pressed using bitwise & like this:

[VarDef,keyOnMouseDown,0]

[Sleep,0.001,
[If,SleepResult==4,//waits for keypress
[VarSet,keyOnMouseDown,
[IGet,Preferences:Utilities:View Keyboard Status]
]
]
[SleepAgain],4,sleepResult
]

[ISubPalette,“Zplugin:Key Test”]

[IButton,“Zplugin:Key Test:Modifier Key Test”,“Test which modifier keys are pressed”,
[VarSet,shiftStr,""]
[VarSet,ctrlStr,""]
[VarSet,altStr,""]
[If,(keyOnMouseDown&256 == 256),

[VarSet,shiftStr,“SHIFT-”]

]
[If,(keyOnMouseDown&512 == 512),

[VarSet,ctrlStr,“CTRL-”]

]
[If,(keyOnMouseDown&1024 == 1024),

[VarSet,altStr,“ALT”]

]
[If,([StrLength,shiftStr]== 0)&&([StrLength,ctrlStr]== 0)&&([StrLength,altStr]== 0),

[VarSet,altStr,“No modifier keys”]

]
[Note,[StrMerge,shiftStr,ctrlStr,altStr," pressed"],3]
//clear status
[IKeyPress,13,[IPress,“Preferences:Utilities:View keyboard status”]]
,1]

However, there are drawbacks. The value for the keyboard status slider isn’t cleared before the previous operation so in some cases the first press of the button will return the wrong result, such as when a modifier key shortcut has used with no mouse down. Also, the Ctrl+Alt combination won’t register because that’s the shortcut for assigning a hotkey.

But using this example you may be able to find a way to do what you want.

I’ll look into the UI config problem later.

super cool Marcus as always your help is precious.
The code works, but finally i decided to continue to use the other approach, and now instead of checking the brush name with
IGetInfo and check for the type of brush( mask or blur).
Also you sleep mode is using the mouse move, which is not really the best event, i would have used 1024 interface item pressed instead.

i took the time to update the information about the second bug about the custom UI.

Also you sleep mode is using the mouse move, which is not really the best event, i would have used 1024 interface item pressed instead.

It’s mouse down rather than move, so the button click registers. And although your idea of using 1024 sounds good, it actually doesn’t work. :slight_smile:

hmm sorry i getting confused, you mean event 1024 about the interface window pressed doesn’t works ?
cause it seems to works pretty well on my side.

hmm sorry i getting confused, you mean event 1024 about the interface window pressed doesn’t works ?
cause it seems to works pretty well on my side.

Yes, doesn’t work for me. That’s why I avoid using [Sleep] if I can.

it work for me, but at discovered a minor bug, when i want to enter a numeric value for a slider, it like the sleep mode awake when i click the slider and can’t a return in sleep mode, i need to find a way to handle that.
i can share the plug so you can tell me if it wokrs for you or not.