IMDTouchKnowledge BaseShop main store

How-to

WinCC library push button latches: how to get press and release

HMI and touchscreens Published 7 min read By IMDTouch engineering team

Short answer

The library push-button switch is a maintained toggle: it exposes Switch on, Switch off, Activate and Deactivate, and no Press or Release, so a bit set on one click stays set until the next click. Use a normal toolbox Button with SetBit on Press and ResetBit on Release, and reuse the library artwork by setting its Mode to Graphic.

On this page
  1. Why the library push button latches
  2. Match the object to the behavior
  3. Configure Press and Release on a toolbox Button
  4. Keep the library artwork in Graphic mode
  5. Worked example: a held jog command on one bit
  6. When the bit still stays true
  7. Supervise the command in the PLC
  8. The decision for each case
  9. Questions asked

The library push button latches because, in the event model, it is not a push button at all: it is a switch. Its event list offers Switch on, Switch off, Activate and Deactivate, with no Press or Release anywhere, so a bit you set on one click stays set until a later click flips it off. The fix is a normal Button from the toolbox, with SetBit on its Press event and ResetBit on its Release event. If you want the library artwork, set that Button's Mode to Graphic and give it the library's released and pressed images.

Why the library push button latches #

Momentary and maintained controls use different event models. A momentary control writes the active state when the input goes down and the inactive state when the input comes up. A maintained control changes state when it is activated and holds that state until a later action changes it back.

The push-button switches in the WinCC button library are maintained controls. The artwork looks like a spring-return push button, but the object is a switch: the first activation fires Switch on, the next fires Switch off, and the object itself holds the state in between. Hang SetBit on one and ResetBit on the other and the tag simply copies the switch: one click sets it, the next click resets it. That is the latch, and no rewiring of those four events turns it into a hold.

Activate and Deactivate do not rescue it. The WinCC Professional V13.0 SP1 documentation describes the Deactivate event as nothing more than a signal that the object was deselected, and in WinCC Unified the Activated and Deactivated events are triggered through mouse, touch or keyboard when an object gains or loses focus: Deactivated arrives when a different object is activated, not when the finger lifts. Focus is not contact. Since the switch has no event that follows the physical release, change the object, not the wiring.

Match the object to the behavior #

Behavior you need Object and event pattern Tag result
True only while held (jog, momentary enable) Toolbox Button: SetBit on Press, ResetBit on Release 1 for exactly the hold
State that stays after each click (start, stop) Library switch with its Switch on and Switch off events Toggles on every activation
One-shot request (recipe start, step advance) Click sets a request bit; the PLC acknowledges and clears it PLC controls completion
Library artwork with momentary action Toolbox Button with Mode set to Graphic and the two library images Momentary action, library look

Click is a completed interaction: it fires once, after press and release are already over, so it carries no hold time. It is right for one-shot requests and navigation, wrong for anything that must drop when the operator lets go.

Configure Press and Release on a toolbox Button #

  1. Drop the library push-button switch onto the screen once, so its two images become available in the project graphics (TIA Portal keeps them under Languages & resources > Project graphics).
  2. Add a normal Button from the toolbox, the Elements panel object whose event list contains Press and Release.
  3. Select the Button and open Properties > Properties > Events.
  4. On Press, add SetBit with your command tag as its parameter; if you write the bit from a script instead, read how SetBit and ResetBit differ in a WinCC script first.
  5. On Release, add ResetBit on the same tag.
  6. Make sure nothing else writes that tag: no Click function, no leftover Switch on assignment, no script, no second object.
  7. Start the runtime and hold the Button: the tag must read 1 for exactly as long as you hold it and 0 the moment you let go.

Keep the library artwork in Graphic mode #

  1. Open Properties > Properties > General on the toolbox Button.
  2. In the Mode box on the left, select Graphic.
  3. Pick the released image in the Graphic field and the pressed image in Graphic when button is pressed, using the small arrow on each input field to choose from the project graphics the library object brought in.
  4. Keep the Press and Release functions from the previous section untouched.
  5. Delete the temporary library switch and confirm both images still display on the Button.

In WinCC Unified the pressed-state setting carries the label "Graphic with pressed button"; the approach is the same. Presentation and command semantics are now separate: the two images show the physical position, while the Button supplies the momentary events.

Worked example: a held jog command on one bit #

Inputs, from the case at hand: a WinCC V13 project; a library push-button switch whose event list shows only Switch on, Switch off, Activate and Deactivate; and the requirement that a conveyor jog command be 1 only while the operator holds the button. The command tag here is Jog_Request, a Boolean tag with initial value 0, an example name, not a system name.

Rule in words: a momentary command needs one object that reports both edges of the hold; write 1 on Press and 0 on Release, on the same tag, with no other writer.

The arithmetic is the state trace. With the library switch:

  • Activation 1: Switch on runs SetBit, so Jog_Request = 1
  • Operator lets go: no event exists, so Jog_Request = 1, unchanged
  • Activation 2: Switch off runs ResetBit, so Jog_Request = 0

The bit is 1 across the whole interval between two separate clicks: the latch.

With the toolbox Button:

  • Press: SetBit runs, so Jog_Request = 1
  • Hold: Jog_Request stays 1
  • Release: ResetBit runs, so Jog_Request = 0

The bit is 1 for exactly the hold, which is the requirement.

Result: the toolbox Button satisfies true-only-while-held; the switch cannot, on any wiring.

Decision: adopt the toolbox Button for every hold command. The threshold for going further is consequence, not size: the moment a stuck 1 can move the machine (jog, axis enable, door drive), the Press and Release pair alone is not enough and the PLC supervises the bit, as described below. For bits that only light lamps or gate screens, the pair alone is enough.

When the bit still stays true #

Work down this list in order:

  • Watch the tag, not the picture. Tag 1 with the input released is a write problem; tag 0 with a pressed picture is the object's own state showing.
  • Check event placement: set on Press, reset on Release. A Switch on and Switch off pair toggles by design.
  • Find every writer of the tag: other screen objects, scripts, PLC logic. A correct reset that is immediately written back looks exactly like a latch.
  • Test with direct event functions instead of scripts, so object behavior is separated from script logic.
  • Test one input method at a time. A reported WinCC V7.5 case on Windows 10 latched the bit when the left mouse button and the spacebar were held together, even with a direct connection; treat that as a symptom to reproduce on your own runtime, not a confirmed defect. If Release never arrives from touch while the mouse behaves, the fault is in the touch input path rather than your wiring, as covered in why a WinCC RT Professional button release works with the mouse but not touch.
  • Hold the Button, drag off it, and navigate away while holding: if focus loss or a screen change swallows the release write, the tag stays 1, which is exactly what the PLC layer below exists for.
  • If the command starts late only when pressed by touch, that is a separate input-latency fault, covered in why touch JOG buttons start late while the mouse works fine.

Supervise the command in the PLC #

The release write can be lost through focus loss, screen change, runtime stop or mixed mouse-and-keyboard input, so anything that moves gets a second layer in the PLC:

  • A request bit the PLC acknowledges and clears, so the HMI never holds a motion command open-ended.
  • A one-shot in the PLC for commands that must execute exactly once.
  • A permissive that drops the command when its operating conditions disappear.
  • A maximum on-duration taken from the machine's functional requirements.
  • Maintained start and stop modes on their own, explicitly named tags, so a toggle is never mistaken for a jog request, and on memory tags, since an HMI toggle switch cannot write a physical PLC input.

One safety line, where it belongs: emergency stops, guard interlocks and safety-rated stops stay in the safety circuit. No safety function runs through an HMI tag, however cleanly the button is wired.

The decision for each case #

  • Hold-to-run command: toolbox Button, SetBit on Press, ResetBit on Release, plus PLC supervision the moment it can move something.
  • Maintained start or stop: keep the library switch, because toggling is what it is built for. Name the tag as maintained and never pretend it is momentary.
  • Library look with momentary action: the toolbox Button in Graphic mode, carrying the library's released and pressed images.

Questions asked

Can a PLC timer rescue the library switch for jog?

No. The switch never reports the release, so the hold is never transmitted and a timer can only guess its length. The operator lets go and the PLC still sees a 1 until the next click or the timer expires, which is not hold-to-run behavior. Move the command to a toolbox Button so both edges, press and release, actually reach the tag.

Does the same fix apply to WinCC Unified?

The artwork part does: Unified labels the pressed-state setting 'Graphic with pressed button'. Its Activated and Deactivated events are documented as focus events, triggered by mouse, touch or keyboard when an object gains or loses focus, so they still cannot carry a hold. Keep the command on the event pair that follows the physical press and release, and prove it with the hold test on your own panel.

The picture stays pressed but my tag reads 0. Is it still latched?

No, the command is fine and the object's display is misleading you. A switch keeps its own internal state, and its artwork follows that state, not the tag you write, so the two can disagree. That mismatch is one more reason to move the command to a toolbox Button, whose pressed graphic follows the actual press.

Do I need a script for the set and reset?

No. SetBit and ResetBit work as plain event functions, and a direct connection can write the tag straight from the event with no code at all. Prefer those first: every script layer between the event and the tag is another place where the release write can be skipped or overwritten. Test the direct-connection version before adding any script logic.

What are Activate and Deactivate good for, then?

Focus-driven behavior. The WinCC documentation says the Deactivate event only signals that the object was deselected and does not trigger a password prompt, which suits highlighting the selected object, committing field edits or screen-flow logic. Keep command bits off that pair.

Keep reading

  • Troubleshooting

    Why a WinCC Professional Button Does Not Write to the PLC

    A pressed button proves only that the screen handled the pointer event. Diagnose in order: the Professional runtime connection, the tag binding, then the command duration — a bit set on press and reset on release can be shorter than the tag's 2-second default update cycle, so the PLC never observes it. The fix is to let PLC logic clear the request after evaluating it.

    HMI and touchscreens

  • Troubleshooting

    WinCC RT Professional button release works with mouse but not touch

    Touch is not failing because RT Professional lacks a touch release event: a single finger that the touchscreen driver reports as a left mouse button fires Release left mouse button just like a physical mouse. Run a ten-click, ten-tap counter test to prove which event the touch input delivers, then keep the momentary action on the left-button press/release pair and add a PLC-side reset for a missed release.

    HMI and touchscreens

  • How-to

    Where to Find the Symbol Library in WinCC Graphics Designer

    In classic WinCC, the symbol library lives inside the Graphics Designer picture editor: open a PDL picture and select View > Library to expose the Global Library and the project library. You extend it with your own WMF or EMF vector files, and custom ActiveX controls reach the palette through Add/Remove Controls.

    HMI and touchscreens

How to get Vijeo Designer Basic 1.1 from the official source