• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X Scripting - TCL
  3. How do I get a click event on schematic in my orcal tcl...

Stats

  • State Suggested Answer
  • Replies 4
  • Answers 1
  • Subscribers 13
  • Views 2209
  • Members are here 0
More Content

How do I get a click event on schematic in my orcal tcl code

Jadystone
Jadystone over 1 year ago

I want to get a click position on schematic to continue code. I write some code, But it can't work. My problem is how to implement this function

package require Tk
namespace eval {
//I want to capture the double-click event on schematic , but it can not work
    RegisterAction "OffpagePositonClick"   "::OffpageCheck::Enabler" "Double-1" "::OffpageCheck::OffpagePositonClick" "schematic"
}


wm withdraw .
toplevel .mywin
wm title .mywin "Modify wire Name"
wm attributes .mywin -toolwindow 1
wm attributes .mywin -topmost 1
global clicked
set clicked 0

label .mywin.label1 -text "Click anywhere in the window to continue..."
button .mywin.modifyBtn  -text "click" -command {
    global clicked
    set clicked 0
    puts "before, clicked=$clicked"
    puts "waiting mouse click"
    #waiting a click on schematic, It can not capture the mouse click event
    vwait clicked
   
    set lPickPosition [GetLastMouseClickPointOnPage]
    set lX  [lindex $lPickPosition 0]
    set lY  [lindex $lPickPosition 1]
    puts "Mouseclick=($lX,$lY)"
    puts "The script has continued after the mouse click."
}

grid .mywin.label1 -row 0 -column 0  -pady 20
grid .mywin.modifyBtn -row 1 -column 0 -pady 20

# Function to handle the mouse click event
proc handleClick {} {
    global clicked
    puts "Mouse clicked! Continuing the script..."
    set clicked 1
}

# Bind the left mouse button click event to the handleClick function
# this work, but it click on the window, I want clicking on schematic window
# bind .mywin <Double-1> {handleClick}
  • Cancel
  • Sign in to reply
Parents
  • JuanCR
    0 JuanCR over 1 year ago

    Hi Jadystone. Allow us some time to debug this code and we'll get back to you. 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Jadystone
    0 Jadystone over 1 year ago in reply to JuanCR

    If I can get the sch window handle, it will work.  I think the bind code should be:

    bind $psch_window <Button-1> {handleClick}

    Probem is how can I get the  $psch_window.

    Current my temporary solution is replacing "vwait clicked" with 

    update

    after 1000

    That can let me to get a click position on sch page. But it must click the sch window within a second. Otherwise It could get a false position that I don't want.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • CadAP
    0 CadAP over 1 year ago in reply to Jadystone

    HI Jadystone,

    To run call the script from schematic is to use right click option and call the function.

    like below:

    proc test1 {args} {

    return 1

    }

    proc test2 {args} {

    puts "clicked"
    }

    RegisterAction "test" "test1" "" "test2" "Schematic"

    You will get option like below:

    Second one:

    Below code will call the script when you double click on the open window, it take input from schematic and process operation on the selected  schematic object. 

    package require Tk

    wm withdraw .
    toplevel .mywin
    wm title .mywin "Modify wire Name"
    wm attributes .mywin -toolwindow 1
    wm attributes .mywin -topmost 1
    global clicked
    set clicked 0

    proc instname {} {

    set lNullObj NULL
    set namelist {}
    set selObj [GetSelectedObjects]
    if {$selObj != "lNullObj"} {
    set lName [DboTclHelper_sMakeCString]
    foreach obj $selObj {

    $obj GetName $lName
    lappend namelist "[DboTclHelper_sGetConstCharPtr $lName]"

    }
    puts $namelist
    }
    }

    proc captureclick {} {

    set lPickPosition [GetLastMouseClickPointOnPage]
    set lX [lindex $lPickPosition 0]
    set lY [lindex $lPickPosition 1]
    puts "\n Mouseclick=($lX,$lY)"
    puts " \n The script has continued after the mouse click."
    instname

    }


    bind .mywin <Double-1> {captureclick}

    Hope this help!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Jadystone
    0 Jadystone over 1 year ago in reply to CadAP

    Thank for your reply. My finial solution is below. 

    The first method is using a delay in the code, and then click the schematic page quickly。

    update

    after 1000

    set lPickPosition [GetLastMouseClickPointOnPage]
    set lX [lindex $lPickPosition 0]
    set lY [lindex $lPickPosition 1]
    puts "\n Mouseclick=($lX,$lY)"
    puts " \n The script has continued after the mouse click."

    the second method is that I click the schematic a position which I expect firstly. Then click the button to continue my next action. In this method. I can get the right mouse clicked position.

    The third is placing sth such as some wires on a spare place. Then use SelectBlock to select the placed. Then cut the selection. At last paste on the schematic.

        set total [llength $wiresTobePlace]
        for {set i 0} {$i < $total } {
            set netname [lindex $wiresTobePlace $i]
            PlaceWire      $x0  $y  [expr $x0 + $PINGAP*10]  $y
            PlaceNetAlias  [expr $x0+$PINGAP] $y $netname
            set y [expr $PINGAP + $y]
        }

        #cut the wires and then paste it at sch
        SelectBlock [expr $x0-$PINGAP] [expr 0-$PINGAP] [expr $x0+11*$PINGAP] [expr  ($total+1)*$PINGAP]  1
        Cut  

    Although the first one is not a perfect solution. I like the first best. We must pay attention to click a position quickly after our action operation executing.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • Jadystone
    0 Jadystone over 1 year ago in reply to CadAP

    Thank for your reply. My finial solution is below. 

    The first method is using a delay in the code, and then click the schematic page quickly。

    update

    after 1000

    set lPickPosition [GetLastMouseClickPointOnPage]
    set lX [lindex $lPickPosition 0]
    set lY [lindex $lPickPosition 1]
    puts "\n Mouseclick=($lX,$lY)"
    puts " \n The script has continued after the mouse click."

    the second method is that I click the schematic a position which I expect firstly. Then click the button to continue my next action. In this method. I can get the right mouse clicked position.

    The third is placing sth such as some wires on a spare place. Then use SelectBlock to select the placed. Then cut the selection. At last paste on the schematic.

        set total [llength $wiresTobePlace]
        for {set i 0} {$i < $total } {
            set netname [lindex $wiresTobePlace $i]
            PlaceWire      $x0  $y  [expr $x0 + $PINGAP*10]  $y
            PlaceNetAlias  [expr $x0+$PINGAP] $y $netname
            set y [expr $PINGAP + $y]
        }

        #cut the wires and then paste it at sch
        SelectBlock [expr $x0-$PINGAP] [expr 0-$PINGAP] [expr $x0+11*$PINGAP] [expr  ($total+1)*$PINGAP]  1
        Cut  

    Although the first one is not a perfect solution. I like the first best. We must pay attention to click a position quickly after our action operation executing.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
No Data
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information