So geht es auch unter MacOS X...mk-soft hat geschrieben:Geht unter Mac auch nicht

Code: Alles auswählen
EnableExplicit
#NSLeftMouseUp = 2
Define CurrentEvent.I
Define DOMNode.I
Define ElementDictionary.I
Define EventType.I
Define IDName.S
Define Point.NSPoint
Define SharedApplication = CocoaMessage(0, 0, "NSApplication sharedApplication")
Define HTML.S
OpenWindow(0, 270, 100, 270, 50, "HTML-Formular")
WebGadget(0, 5, 5, WindowWidth(0) - 10, WindowHeight(0) - 10, "")
; ----- HTML-Formular mit Anzeige von 2 Buttons
HTML = "<html>" +
"<body>" +
"<input type='button' value='Klick mich!' id='Button1'>" +
"<input type='button' value='Nein, lieber mich!' id='Button2'>" +
"</body>" +
"</html>"
; ----- HTML-Formular ins WebGadget laden und anzeigen
CocoaMessage(0, CocoaMessage(0, GadgetID(0), "mainFrame"),
"loadHTMLString:$", @HTML,
"baseURL:", 0)
Repeat
CurrentEvent = CocoaMessage(0, SharedApplication, "currentEvent")
If CurrentEvent
EventType = CocoaMessage(0, CurrentEvent, "type")
If EventType = #NSLeftMouseUp
; ----- Ermittle Mausklick-Position
CocoaMessage(@Point, CurrentEvent, "locationInWindow")
; ----- Infos über HTML-Element an Mausklick-Position anfordern
CocoaMessage(@ElementDictionary, GadgetID(0),
"elementAtPoint:@", @Point)
; ----- DOMNode ermitteln
DOMNode = CocoaMessage(0, ElementDictionary,
"objectForKey:$", @"WebElementDOMNode")
If DOMNode
IDName = PeekS(CocoaMessage(0, CocoaMessage(0, DOMNode, "idName"),
"UTF8String"), -1, #PB_UTF8)
If Left(IDName, 6) = "Button"
Debug "Linksklick auf " + IDName
EndIf
EndIf
EndIf
EndIf
Until WaitWindowEvent() = #PB_Event_CloseWindow