Example #1
0
func (e *Element) ValueAsString() (string, error) {
	args := &textValueParams{MethodId: GET_TEXT_VALUE}
	ret := C.HTMLayoutCallBehaviorMethod(e.handle, (*C.METHOD_PARAMS)(unsafe.Pointer(args)))
	if ret == HLDOM_OK_NOT_HANDLED {
		domPanic(ret, "This type of element does not provide data in this way.  Try a <widget>.")
	} else if ret != HLDOM_OK {
		domPanic(ret, "Could not get text value")
	}
	if args.Text == nil {
		return "", errors.New("Nil string pointer")
	}
	return utf16ToStringLength(args.Text, int(args.Length)), nil
}
Example #2
0
func (e *Element) SetValue(value interface{}) {
	switch v := value.(type) {
	case string:
		args := &textValueParams{
			MethodId: SET_TEXT_VALUE,
			Text:     stringToUtf16Ptr(v),
			Length:   uint32(len(v)),
		}
		ret := C.HTMLayoutCallBehaviorMethod(e.handle, (*C.METHOD_PARAMS)(unsafe.Pointer(args)))
		if ret == HLDOM_OK_NOT_HANDLED {
			domPanic(ret, "This type of element does not accept data in this way.  Try a <widget>.")
		} else if ret != HLDOM_OK {
			domPanic(ret, "Could not set text value")
		}
	default:
		panic("Don't know how to set values of this type")
	}
}