1. #1
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default 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.
    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

  2. #2
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default

    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
    ]

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

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

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

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

    6. 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.


    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

  3. #3
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default

    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.
    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

  4. #4
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    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.

  5. #5
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default

    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.
    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

  6. #6
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    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.

  7. #7
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default

    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.
    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

  8. #8
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    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.

  9. #9
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default

    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.
    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •